diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index e67f45afc4a6..9dd8744d0d03 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -1,11 +1,11 @@ { - "commit": "3e3098d6b9302e166b611ce72b3392786d3ea0f7", + "commit": "f10704e0351741c016de4a179c386ab6b9cbc370", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.7", "use": [ "@autorest/python@6.7.1", "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/sql/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --tag=package-composite-v5 --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/sql/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/sql/resource-manager/readme.md" } \ No newline at end of file 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 3a167186aac7..5cf165b90903 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_configuration.py @@ -29,10 +29,15 @@ class SqlManagementClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SqlManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -40,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-sql/{}".format(VERSION)) self._configure(**kwargs) 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 4dd2b42b6868..2e7489ec9840 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 @@ -46,8 +46,6 @@ DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, - ElasticPoolActivitiesOperations, - ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, @@ -63,6 +61,7 @@ JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, + JobPrivateEndpointsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, @@ -109,6 +108,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -127,7 +127,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -140,7 +139,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -177,34 +175,48 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases. + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.operations.BackupShortTermRetentionPoliciesOperations + :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations + :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 + :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 data_masking_policies: DataMaskingPoliciesOperations operations :vartype data_masking_policies: azure.mgmt.sql.operations.DataMaskingPoliciesOperations :ivar data_masking_rules: DataMaskingRulesOperations operations :vartype data_masking_rules: azure.mgmt.sql.operations.DataMaskingRulesOperations - :ivar geo_backup_policies: GeoBackupPoliciesOperations operations - :vartype geo_backup_policies: azure.mgmt.sql.operations.GeoBackupPoliciesOperations - :ivar databases: DatabasesOperations operations - :vartype databases: azure.mgmt.sql.operations.DatabasesOperations - :ivar elastic_pools: ElasticPoolsOperations operations - :vartype elastic_pools: azure.mgmt.sql.operations.ElasticPoolsOperations - :ivar server_communication_links: ServerCommunicationLinksOperations operations - :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 - :ivar server_usages: ServerUsagesOperations operations - :vartype server_usages: azure.mgmt.sql.operations.ServerUsagesOperations + :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations + :ivar database_advanced_threat_protection_settings: + DatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype database_advanced_threat_protection_settings: + azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations :ivar database_advisors: DatabaseAdvisorsOperations operations :vartype database_advisors: azure.mgmt.sql.operations.DatabaseAdvisorsOperations :ivar database_automatic_tuning: DatabaseAutomaticTuningOperations operations :vartype database_automatic_tuning: azure.mgmt.sql.operations.DatabaseAutomaticTuningOperations :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.operations.DatabaseColumnsOperations + :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations + :vartype database_encryption_protectors: + azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations + :ivar database_extensions: DatabaseExtensionsOperations operations + :vartype database_extensions: azure.mgmt.sql.operations.DatabaseExtensionsOperations + :ivar database_operations: DatabaseOperationsOperations operations + :vartype database_operations: azure.mgmt.sql.operations.DatabaseOperationsOperations :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations :vartype database_recommended_actions: azure.mgmt.sql.operations.DatabaseRecommendedActionsOperations @@ -213,30 +225,70 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations :vartype database_security_alert_policies: azure.mgmt.sql.operations.DatabaseSecurityAlertPoliciesOperations + :ivar database_sql_vulnerability_assessment_baselines: + DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_baselines: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations + :ivar database_sql_vulnerability_assessment_execute_scan: + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype database_sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations + :ivar database_sql_vulnerability_assessment_rule_baselines: + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_sql_vulnerability_assessment_scan_result: + DatabaseSqlVulnerabilityAssessmentScanResultOperations operations + :vartype database_sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations + :ivar database_sql_vulnerability_assessment_scans: + DatabaseSqlVulnerabilityAssessmentScansOperations operations + :vartype database_sql_vulnerability_assessment_scans: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations + :ivar database_sql_vulnerability_assessments_settings: + DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations + :vartype database_sql_vulnerability_assessments_settings: + azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations :ivar database_tables: DatabaseTablesOperations operations :vartype database_tables: azure.mgmt.sql.operations.DatabaseTablesOperations + :ivar database_usages: DatabaseUsagesOperations operations + :vartype database_usages: azure.mgmt.sql.operations.DatabaseUsagesOperations :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 - :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations - :vartype data_warehouse_user_activities: - azure.mgmt.sql.operations.DataWarehouseUserActivitiesOperations + :ivar database_vulnerability_assessments: DatabaseVulnerabilityAssessmentsOperations operations + :vartype database_vulnerability_assessments: + azure.mgmt.sql.operations.DatabaseVulnerabilityAssessmentsOperations + :ivar databases: DatabasesOperations operations + :vartype databases: azure.mgmt.sql.operations.DatabasesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.operations.DeletedServersOperations + :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations + :vartype distributed_availability_groups: + azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations :vartype elastic_pool_operations: azure.mgmt.sql.operations.ElasticPoolOperationsOperations + :ivar elastic_pools: ElasticPoolsOperations operations + :vartype elastic_pools: azure.mgmt.sql.operations.ElasticPoolsOperations :ivar encryption_protectors: EncryptionProtectorsOperations operations :vartype encryption_protectors: azure.mgmt.sql.operations.EncryptionProtectorsOperations + :ivar endpoint_certificates: EndpointCertificatesOperations operations + :vartype endpoint_certificates: azure.mgmt.sql.operations.EndpointCertificatesOperations + :ivar failover_groups: FailoverGroupsOperations operations + :vartype failover_groups: azure.mgmt.sql.operations.FailoverGroupsOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.sql.operations.FirewallRulesOperations + :ivar geo_backup_policies: GeoBackupPoliciesOperations operations + :vartype geo_backup_policies: azure.mgmt.sql.operations.GeoBackupPoliciesOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations + :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations + :vartype instance_failover_groups: azure.mgmt.sql.operations.InstanceFailoverGroupsOperations :ivar instance_pools: InstancePoolsOperations operations :vartype instance_pools: azure.mgmt.sql.operations.InstancePoolsOperations :ivar job_agents: JobAgentsOperations operations @@ -245,8 +297,8 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype job_credentials: azure.mgmt.sql.operations.JobCredentialsOperations :ivar job_executions: JobExecutionsOperations operations :vartype job_executions: azure.mgmt.sql.operations.JobExecutionsOperations - :ivar jobs: JobsOperations operations - :vartype jobs: azure.mgmt.sql.operations.JobsOperations + :ivar job_private_endpoints: JobPrivateEndpointsOperations operations + :vartype job_private_endpoints: azure.mgmt.sql.operations.JobPrivateEndpointsOperations :ivar job_step_executions: JobStepExecutionsOperations operations :vartype job_step_executions: azure.mgmt.sql.operations.JobStepExecutionsOperations :ivar job_steps: JobStepsOperations operations @@ -257,8 +309,19 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype job_target_groups: azure.mgmt.sql.operations.JobTargetGroupsOperations :ivar job_versions: JobVersionsOperations operations :vartype job_versions: azure.mgmt.sql.operations.JobVersionsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.sql.operations.JobsOperations + :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations + :vartype ledger_digest_uploads: azure.mgmt.sql.operations.LedgerDigestUploadsOperations :ivar capabilities: CapabilitiesOperations operations :vartype capabilities: azure.mgmt.sql.operations.CapabilitiesOperations + :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 :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations :vartype long_term_retention_policies: azure.mgmt.sql.operations.LongTermRetentionPoliciesOperations @@ -271,10 +334,20 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedBackupShortTermRetentionPoliciesOperations operations :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.operations.ManagedBackupShortTermRetentionPoliciesOperations + :ivar managed_database_advanced_threat_protection_settings: + ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype managed_database_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations :vartype managed_database_columns: azure.mgmt.sql.operations.ManagedDatabaseColumnsOperations + :ivar managed_database_move_operations: ManagedDatabaseMoveOperationsOperations operations + :vartype managed_database_move_operations: + azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations :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 :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations :vartype managed_database_schemas: azure.mgmt.sql.operations.ManagedDatabaseSchemasOperations :ivar managed_database_security_alert_policies: ManagedDatabaseSecurityAlertPoliciesOperations @@ -284,6 +357,14 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :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 :ivar managed_database_tables: ManagedDatabaseTablesOperations operations :vartype managed_database_tables: azure.mgmt.sql.operations.ManagedDatabaseTablesOperations :ivar managed_database_transparent_data_encryption: @@ -294,21 +375,29 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword 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_vulnerability_assessments: + ManagedDatabaseVulnerabilityAssessmentsOperations operations + :vartype managed_database_vulnerability_assessments: + azure.mgmt.sql.operations.ManagedDatabaseVulnerabilityAssessmentsOperations + :ivar managed_databases: ManagedDatabasesOperations operations + :vartype managed_databases: azure.mgmt.sql.operations.ManagedDatabasesOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations :vartype managed_instance_administrators: azure.mgmt.sql.operations.ManagedInstanceAdministratorsOperations + :ivar managed_instance_advanced_threat_protection_settings: + ManagedInstanceAdvancedThreatProtectionSettingsOperations operations + :vartype managed_instance_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations :ivar managed_instance_azure_ad_only_authentications: ManagedInstanceAzureADOnlyAuthenticationsOperations operations :vartype managed_instance_azure_ad_only_authentications: azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations + :ivar managed_instance_dtcs: ManagedInstanceDtcsOperations operations + :vartype managed_instance_dtcs: azure.mgmt.sql.operations.ManagedInstanceDtcsOperations :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations operations :vartype managed_instance_encryption_protectors: @@ -337,26 +426,60 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedInstanceVulnerabilityAssessmentsOperations operations :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.operations.ManagedInstanceVulnerabilityAssessmentsOperations + :ivar managed_instances: ManagedInstancesOperations operations + :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations + :ivar managed_ledger_digest_uploads: ManagedLedgerDigestUploadsOperations operations + :vartype managed_ledger_digest_uploads: + azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations :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_dns_aliases: ManagedServerDnsAliasesOperations operations + :vartype managed_server_dns_aliases: + azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations operations :vartype managed_server_security_alert_policies: azure.mgmt.sql.operations.ManagedServerSecurityAlertPoliciesOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.sql.operations.NetworkSecurityPerimeterConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sql.operations.Operations + :ivar outbound_firewall_rules: OutboundFirewallRulesOperations operations + :vartype outbound_firewall_rules: azure.mgmt.sql.operations.OutboundFirewallRulesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :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_databases: RecoverableDatabasesOperations operations + :vartype recoverable_databases: azure.mgmt.sql.operations.RecoverableDatabasesOperations :ivar recoverable_managed_databases: RecoverableManagedDatabasesOperations operations :vartype recoverable_managed_databases: azure.mgmt.sql.operations.RecoverableManagedDatabasesOperations + :ivar replication_links: ReplicationLinksOperations operations + :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations + :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 :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 + :ivar server_advanced_threat_protection_settings: + ServerAdvancedThreatProtectionSettingsOperations operations + :vartype server_advanced_threat_protection_settings: + azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations :ivar server_advisors: ServerAdvisorsOperations operations :vartype server_advisors: azure.mgmt.sql.operations.ServerAdvisorsOperations :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations @@ -368,6 +491,12 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword operations :vartype server_azure_ad_only_authentications: azure.mgmt.sql.operations.ServerAzureADOnlyAuthenticationsOperations + :ivar server_configuration_options: ServerConfigurationOptionsOperations operations + :vartype server_configuration_options: + azure.mgmt.sql.operations.ServerConfigurationOptionsOperations + :ivar server_connection_policies: ServerConnectionPoliciesOperations operations + :vartype server_connection_policies: + azure.mgmt.sql.operations.ServerConnectionPoliciesOperations :ivar server_dev_ops_audit_settings: ServerDevOpsAuditSettingsOperations operations :vartype server_dev_ops_audit_settings: azure.mgmt.sql.operations.ServerDevOpsAuditSettingsOperations @@ -380,15 +509,61 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations :vartype server_security_alert_policies: azure.mgmt.sql.operations.ServerSecurityAlertPoliciesOperations + :ivar server_trust_certificates: ServerTrustCertificatesOperations operations + :vartype server_trust_certificates: azure.mgmt.sql.operations.ServerTrustCertificatesOperations :ivar server_trust_groups: ServerTrustGroupsOperations operations :vartype server_trust_groups: azure.mgmt.sql.operations.ServerTrustGroupsOperations + :ivar server_usages: ServerUsagesOperations operations + :vartype server_usages: azure.mgmt.sql.operations.ServerUsagesOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations :vartype server_vulnerability_assessments: azure.mgmt.sql.operations.ServerVulnerabilityAssessmentsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.sql.operations.ServersOperations :ivar sql_agent: SqlAgentOperations operations :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations + :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations + operations + :vartype sql_vulnerability_assessment_baseline: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations + :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations + operations + :vartype sql_vulnerability_assessment_baselines: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations + :ivar sql_vulnerability_assessment_execute_scan: + SqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_rule_baseline: + SqlVulnerabilityAssessmentRuleBaselineOperations operations + :vartype sql_vulnerability_assessment_rule_baseline: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations + :ivar sql_vulnerability_assessment_rule_baselines: + SqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations + operations + :vartype sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations + :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations + operations + :vartype sql_vulnerability_assessments_settings: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations + :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations + :vartype sql_vulnerability_assessments: + azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations + :ivar start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations + operations + :vartype start_stop_managed_instance_schedules: + azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations :ivar subscription_usages: SubscriptionUsagesOperations operations :vartype subscription_usages: azure.mgmt.sql.operations.SubscriptionUsagesOperations + :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations + :vartype synapse_link_workspaces: azure.mgmt.sql.operations.SynapseLinkWorkspacesOperations :ivar sync_agents: SyncAgentsOperations operations :vartype sync_agents: azure.mgmt.sql.operations.SyncAgentsOperations :ivar sync_groups: SyncGroupsOperations operations @@ -399,206 +574,28 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype tde_certificates: azure.mgmt.sql.operations.TdeCertificatesOperations :ivar time_zones: TimeZonesOperations operations :vartype time_zones: azure.mgmt.sql.operations.TimeZonesOperations + :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations + :vartype transparent_data_encryptions: + azure.mgmt.sql.operations.TransparentDataEncryptionsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.sql.operations.UsagesOperations + :ivar virtual_clusters: VirtualClustersOperations operations + :vartype virtual_clusters: azure.mgmt.sql.operations.VirtualClustersOperations :ivar virtual_network_rules: VirtualNetworkRulesOperations operations :vartype virtual_network_rules: azure.mgmt.sql.operations.VirtualNetworkRulesOperations :ivar workload_classifiers: WorkloadClassifiersOperations operations :vartype workload_classifiers: azure.mgmt.sql.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.operations.WorkloadGroupsOperations - :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 - :vartype database_operations: azure.mgmt.sql.operations.DatabaseOperationsOperations - :ivar database_usages: DatabaseUsagesOperations operations - :vartype database_usages: azure.mgmt.sql.operations.DatabaseUsagesOperations - :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations - :vartype ledger_digest_uploads: azure.mgmt.sql.operations.LedgerDigestUploadsOperations - :ivar outbound_firewall_rules: OutboundFirewallRulesOperations operations - :vartype outbound_firewall_rules: azure.mgmt.sql.operations.OutboundFirewallRulesOperations - :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 - :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 - :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations - :vartype distributed_availability_groups: - azure.mgmt.sql.operations.DistributedAvailabilityGroupsOperations - :ivar server_trust_certificates: ServerTrustCertificatesOperations operations - :vartype server_trust_certificates: azure.mgmt.sql.operations.ServerTrustCertificatesOperations - :ivar endpoint_certificates: EndpointCertificatesOperations operations - :vartype endpoint_certificates: azure.mgmt.sql.operations.EndpointCertificatesOperations - :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 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 - :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :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 - :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 database_advanced_threat_protection_settings: - DatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype database_advanced_threat_protection_settings: - azure.mgmt.sql.operations.DatabaseAdvancedThreatProtectionSettingsOperations - :ivar server_advanced_threat_protection_settings: - ServerAdvancedThreatProtectionSettingsOperations operations - :vartype server_advanced_threat_protection_settings: - azure.mgmt.sql.operations.ServerAdvancedThreatProtectionSettingsOperations - :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations - :vartype managed_server_dns_aliases: - azure.mgmt.sql.operations.ManagedServerDnsAliasesOperations - :ivar managed_database_advanced_threat_protection_settings: - ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype managed_database_advanced_threat_protection_settings: - azure.mgmt.sql.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations - :ivar managed_instance_advanced_threat_protection_settings: - ManagedInstanceAdvancedThreatProtectionSettingsOperations operations - :vartype managed_instance_advanced_threat_protection_settings: - azure.mgmt.sql.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations - :ivar replication_links: ReplicationLinksOperations operations - :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations - :ivar managed_database_move_operations: ManagedDatabaseMoveOperationsOperations operations - :vartype managed_database_move_operations: - azure.mgmt.sql.operations.ManagedDatabaseMoveOperationsOperations - :ivar managed_instance_dtcs: ManagedInstanceDtcsOperations operations - :vartype managed_instance_dtcs: azure.mgmt.sql.operations.ManagedInstanceDtcsOperations - :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations - :vartype synapse_link_workspaces: azure.mgmt.sql.operations.SynapseLinkWorkspacesOperations - :ivar virtual_clusters: VirtualClustersOperations operations - :vartype virtual_clusters: azure.mgmt.sql.operations.VirtualClustersOperations - :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations - :vartype instance_failover_groups: azure.mgmt.sql.operations.InstanceFailoverGroupsOperations - :ivar managed_database_restore_details: ManagedDatabaseRestoreDetailsOperations operations - :vartype managed_database_restore_details: - azure.mgmt.sql.operations.ManagedDatabaseRestoreDetailsOperations - :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations - :vartype database_encryption_protectors: - azure.mgmt.sql.operations.DatabaseEncryptionProtectorsOperations - :ivar managed_databases: ManagedDatabasesOperations operations - :vartype managed_databases: azure.mgmt.sql.operations.ManagedDatabasesOperations - :ivar managed_instances: ManagedInstancesOperations operations - :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations - :ivar managed_ledger_digest_uploads: ManagedLedgerDigestUploadsOperations operations - :vartype managed_ledger_digest_uploads: - azure.mgmt.sql.operations.ManagedLedgerDigestUploadsOperations - :ivar recoverable_databases: RecoverableDatabasesOperations operations - :vartype recoverable_databases: azure.mgmt.sql.operations.RecoverableDatabasesOperations - :ivar restorable_dropped_databases: RestorableDroppedDatabasesOperations operations - :vartype restorable_dropped_databases: - azure.mgmt.sql.operations.RestorableDroppedDatabasesOperations - :ivar server_configuration_options: ServerConfigurationOptionsOperations operations - :vartype server_configuration_options: - azure.mgmt.sql.operations.ServerConfigurationOptionsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.sql.operations.ServersOperations - :ivar start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations - operations - :vartype start_stop_managed_instance_schedules: - azure.mgmt.sql.operations.StartStopManagedInstanceSchedulesOperations - :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: - azure.mgmt.sql.operations.TransparentDataEncryptionsOperations - :ivar failover_groups: FailoverGroupsOperations operations - :vartype failover_groups: azure.mgmt.sql.operations.FailoverGroupsOperations - :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations - :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations - operations - :vartype sql_vulnerability_assessment_baseline: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselineOperations - :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations - operations - :vartype sql_vulnerability_assessment_baselines: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentBaselinesOperations - :ivar sql_vulnerability_assessment_execute_scan: - SqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentExecuteScanOperations - :ivar sql_vulnerability_assessment_rule_baseline: - SqlVulnerabilityAssessmentRuleBaselineOperations operations - :vartype sql_vulnerability_assessment_rule_baseline: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselineOperations - :ivar sql_vulnerability_assessment_rule_baselines: - SqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations - operations - :vartype sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScanResultOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations - operations - :vartype sql_vulnerability_assessments_settings: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsSettingsOperations - :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations - :vartype sql_vulnerability_assessments: - azure.mgmt.sql.operations.SqlVulnerabilityAssessmentsOperations - :ivar database_sql_vulnerability_assessment_baselines: - DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_baselines: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations - :ivar database_sql_vulnerability_assessment_execute_scan: - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype database_sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations - :ivar database_sql_vulnerability_assessment_rule_baselines: - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar database_sql_vulnerability_assessment_scan_result: - DatabaseSqlVulnerabilityAssessmentScanResultOperations operations - :vartype database_sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations - :ivar database_sql_vulnerability_assessment_scans: - DatabaseSqlVulnerabilityAssessmentScansOperations operations - :vartype database_sql_vulnerability_assessment_scans: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentScansOperations - :ivar database_sql_vulnerability_assessments_settings: - DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations - :vartype database_sql_vulnerability_assessments_settings: - azure.mgmt.sql.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -619,360 +616,346 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_masking_policies = DataMaskingPoliciesOperations( + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_masking_rules = DataMaskingRulesOperations( + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.geo_backup_policies = GeoBackupPoliciesOperations( + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( 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.server_communication_links = ServerCommunicationLinksOperations( + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service_objectives = ServiceObjectivesOperations( + self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( + self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( + self.data_masking_rules = DataMaskingRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_advisors = DatabaseAdvisorsOperations( + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_columns = DatabaseColumnsOperations( + self.database_advisors = DatabaseAdvisorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( + self.database_automatic_tuning = DatabaseAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_schemas = DatabaseSchemasOperations( + self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( 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.database_extensions = DatabaseExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( + self.database_operations = DatabaseOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + self.database_schemas = DatabaseSchemasOperations( 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.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.encryption_protectors = EncryptionProtectorsOperations( + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.firewall_rules = FirewallRulesOperations(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.database_sql_vulnerability_assessment_execute_scan = ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( + 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.database_sql_vulnerability_assessment_rule_baselines = ( + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.job_target_groups = JobTargetGroupsOperations( + self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( 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.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_windows = MaintenanceWindowsOperations( + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_columns = ManagedDatabaseColumnsOperations( + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_queries = ManagedDatabaseQueriesOperations( + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( + self.elastic_pool_operations = ElasticPoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( + self.endpoint_certificates = EndpointCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_tables = ManagedDatabaseTablesOperations( + 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.geo_backup_policies = GeoBackupPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( 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.instance_failover_groups = InstanceFailoverGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + 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.job_private_endpoints = JobPrivateEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( + self.job_step_executions = JobStepExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( + 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.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( + self.job_target_groups = JobTargetGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_keys = ManagedInstanceKeysOperations( + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_operations = ManagedInstanceOperationsOperations( + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( + self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( + self.maintenance_window_options = MaintenanceWindowOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( + self.maintenance_windows = MaintenanceWindowsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self.managed_database_advanced_threat_protection_settings = ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations( 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.managed_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( + self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restore_points = RestorePointsOperations(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.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( + self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dns_aliases = ServerDnsAliasesOperations( + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( 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.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_groups = ServerTrustGroupsOperations( + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - 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.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( 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.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self.managed_instance_advanced_threat_protection_settings = ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.database_extensions = DatabaseExtensionsOperations( + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( 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.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( + self.managed_instance_keys = ManagedInstanceKeysOperations( 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.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self.managed_instance_operations = ManagedInstanceOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( 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_restorable_dropped_database_backup_short_term_retention_policies = ( + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.sensitivity_labels = SensitivityLabelsOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_firewall_rules = OutboundFirewallRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_advanced_threat_protection_settings = ( - ManagedDatabaseAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_instance_advanced_threat_protection_settings = ( - ManagedInstanceAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.replication_links = ReplicationLinksOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + 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.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( + self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + 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.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instances = ManagedInstancesOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + 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_configuration_options = ServerConfigurationOptionsOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -1000,28 +983,36 @@ def __init__( self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_execute_scan = ( - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.subscription_usages = SubscriptionUsagesOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_rule_baselines = ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + 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.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.usages = UsagesOperations(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) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 841c0583b8fe..c78e629b6f08 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "4.0.0b12" +VERSION = "0.9.0" 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 dd110fbdd091..ebfa665d92b5 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 @@ -29,10 +29,15 @@ class SqlManagementClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SqlManagementClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01-preview") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -40,6 +45,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-sql/{}".format(VERSION)) self._configure(**kwargs) 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 5173540a8a34..e2e933403ce0 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 @@ -46,8 +46,6 @@ DatabasesOperations, DeletedServersOperations, DistributedAvailabilityGroupsOperations, - ElasticPoolActivitiesOperations, - ElasticPoolDatabaseActivitiesOperations, ElasticPoolOperationsOperations, ElasticPoolsOperations, EncryptionProtectorsOperations, @@ -63,6 +61,7 @@ JobAgentsOperations, JobCredentialsOperations, JobExecutionsOperations, + JobPrivateEndpointsOperations, JobStepExecutionsOperations, JobStepsOperations, JobTargetExecutionsOperations, @@ -109,6 +108,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -127,7 +127,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -140,7 +139,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -177,28 +175,35 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases. + :ivar backup_short_term_retention_policies: BackupShortTermRetentionPoliciesOperations + operations + :vartype backup_short_term_retention_policies: + azure.mgmt.sql.aio.operations.BackupShortTermRetentionPoliciesOperations + :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations + :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 + :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 data_masking_policies: DataMaskingPoliciesOperations operations :vartype data_masking_policies: azure.mgmt.sql.aio.operations.DataMaskingPoliciesOperations :ivar data_masking_rules: DataMaskingRulesOperations operations :vartype data_masking_rules: azure.mgmt.sql.aio.operations.DataMaskingRulesOperations - :ivar geo_backup_policies: GeoBackupPoliciesOperations operations - :vartype geo_backup_policies: azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations - :ivar databases: DatabasesOperations operations - :vartype databases: azure.mgmt.sql.aio.operations.DatabasesOperations - :ivar elastic_pools: ElasticPoolsOperations operations - :vartype elastic_pools: azure.mgmt.sql.aio.operations.ElasticPoolsOperations - :ivar server_communication_links: ServerCommunicationLinksOperations operations - :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 - :ivar server_usages: ServerUsagesOperations operations - :vartype server_usages: azure.mgmt.sql.aio.operations.ServerUsagesOperations + :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations + :vartype data_warehouse_user_activities: + azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations + :ivar database_advanced_threat_protection_settings: + DatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype database_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations :ivar database_advisors: DatabaseAdvisorsOperations operations :vartype database_advisors: azure.mgmt.sql.aio.operations.DatabaseAdvisorsOperations :ivar database_automatic_tuning: DatabaseAutomaticTuningOperations operations @@ -206,6 +211,13 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword azure.mgmt.sql.aio.operations.DatabaseAutomaticTuningOperations :ivar database_columns: DatabaseColumnsOperations operations :vartype database_columns: azure.mgmt.sql.aio.operations.DatabaseColumnsOperations + :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations + :vartype database_encryption_protectors: + azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations + :ivar database_extensions: DatabaseExtensionsOperations operations + :vartype database_extensions: azure.mgmt.sql.aio.operations.DatabaseExtensionsOperations + :ivar database_operations: DatabaseOperationsOperations operations + :vartype database_operations: azure.mgmt.sql.aio.operations.DatabaseOperationsOperations :ivar database_recommended_actions: DatabaseRecommendedActionsOperations operations :vartype database_recommended_actions: azure.mgmt.sql.aio.operations.DatabaseRecommendedActionsOperations @@ -214,30 +226,71 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :ivar database_security_alert_policies: DatabaseSecurityAlertPoliciesOperations operations :vartype database_security_alert_policies: azure.mgmt.sql.aio.operations.DatabaseSecurityAlertPoliciesOperations + :ivar database_sql_vulnerability_assessment_baselines: + DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_baselines: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations + :ivar database_sql_vulnerability_assessment_execute_scan: + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype database_sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations + :ivar database_sql_vulnerability_assessment_rule_baselines: + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype database_sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar database_sql_vulnerability_assessment_scan_result: + DatabaseSqlVulnerabilityAssessmentScanResultOperations operations + :vartype database_sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations + :ivar database_sql_vulnerability_assessment_scans: + DatabaseSqlVulnerabilityAssessmentScansOperations operations + :vartype database_sql_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations + :ivar database_sql_vulnerability_assessments_settings: + DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations + :vartype database_sql_vulnerability_assessments_settings: + azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations :ivar database_tables: DatabaseTablesOperations operations :vartype database_tables: azure.mgmt.sql.aio.operations.DatabaseTablesOperations + :ivar database_usages: DatabaseUsagesOperations operations + :vartype database_usages: azure.mgmt.sql.aio.operations.DatabaseUsagesOperations :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 - :ivar data_warehouse_user_activities: DataWarehouseUserActivitiesOperations operations - :vartype data_warehouse_user_activities: - azure.mgmt.sql.aio.operations.DataWarehouseUserActivitiesOperations + :ivar database_vulnerability_assessments: DatabaseVulnerabilityAssessmentsOperations operations + :vartype database_vulnerability_assessments: + azure.mgmt.sql.aio.operations.DatabaseVulnerabilityAssessmentsOperations + :ivar databases: DatabasesOperations operations + :vartype databases: azure.mgmt.sql.aio.operations.DatabasesOperations :ivar deleted_servers: DeletedServersOperations operations :vartype deleted_servers: azure.mgmt.sql.aio.operations.DeletedServersOperations + :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations + :vartype distributed_availability_groups: + azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations :ivar elastic_pool_operations: ElasticPoolOperationsOperations operations :vartype elastic_pool_operations: azure.mgmt.sql.aio.operations.ElasticPoolOperationsOperations + :ivar elastic_pools: ElasticPoolsOperations operations + :vartype elastic_pools: azure.mgmt.sql.aio.operations.ElasticPoolsOperations :ivar encryption_protectors: EncryptionProtectorsOperations operations :vartype encryption_protectors: azure.mgmt.sql.aio.operations.EncryptionProtectorsOperations + :ivar endpoint_certificates: EndpointCertificatesOperations operations + :vartype endpoint_certificates: azure.mgmt.sql.aio.operations.EndpointCertificatesOperations + :ivar failover_groups: FailoverGroupsOperations operations + :vartype failover_groups: azure.mgmt.sql.aio.operations.FailoverGroupsOperations :ivar firewall_rules: FirewallRulesOperations operations :vartype firewall_rules: azure.mgmt.sql.aio.operations.FirewallRulesOperations + :ivar geo_backup_policies: GeoBackupPoliciesOperations operations + :vartype geo_backup_policies: azure.mgmt.sql.aio.operations.GeoBackupPoliciesOperations + :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations + :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations + :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations + :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 @@ -246,8 +299,8 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype job_credentials: azure.mgmt.sql.aio.operations.JobCredentialsOperations :ivar job_executions: JobExecutionsOperations operations :vartype job_executions: azure.mgmt.sql.aio.operations.JobExecutionsOperations - :ivar jobs: JobsOperations operations - :vartype jobs: azure.mgmt.sql.aio.operations.JobsOperations + :ivar job_private_endpoints: JobPrivateEndpointsOperations operations + :vartype job_private_endpoints: azure.mgmt.sql.aio.operations.JobPrivateEndpointsOperations :ivar job_step_executions: JobStepExecutionsOperations operations :vartype job_step_executions: azure.mgmt.sql.aio.operations.JobStepExecutionsOperations :ivar job_steps: JobStepsOperations operations @@ -258,8 +311,19 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype job_target_groups: azure.mgmt.sql.aio.operations.JobTargetGroupsOperations :ivar job_versions: JobVersionsOperations operations :vartype job_versions: azure.mgmt.sql.aio.operations.JobVersionsOperations + :ivar jobs: JobsOperations operations + :vartype jobs: azure.mgmt.sql.aio.operations.JobsOperations + :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations + :vartype ledger_digest_uploads: azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations :ivar capabilities: CapabilitiesOperations operations :vartype capabilities: azure.mgmt.sql.aio.operations.CapabilitiesOperations + :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 :ivar long_term_retention_policies: LongTermRetentionPoliciesOperations operations :vartype long_term_retention_policies: azure.mgmt.sql.aio.operations.LongTermRetentionPoliciesOperations @@ -272,12 +336,22 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedBackupShortTermRetentionPoliciesOperations operations :vartype managed_backup_short_term_retention_policies: azure.mgmt.sql.aio.operations.ManagedBackupShortTermRetentionPoliciesOperations + :ivar managed_database_advanced_threat_protection_settings: + ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations + :vartype managed_database_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations :ivar managed_database_columns: ManagedDatabaseColumnsOperations operations :vartype managed_database_columns: azure.mgmt.sql.aio.operations.ManagedDatabaseColumnsOperations + :ivar managed_database_move_operations: ManagedDatabaseMoveOperationsOperations operations + :vartype managed_database_move_operations: + azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations :ivar managed_database_queries: ManagedDatabaseQueriesOperations operations :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 :ivar managed_database_schemas: ManagedDatabaseSchemasOperations operations :vartype managed_database_schemas: azure.mgmt.sql.aio.operations.ManagedDatabaseSchemasOperations @@ -288,6 +362,14 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :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 :ivar managed_database_tables: ManagedDatabaseTablesOperations operations :vartype managed_database_tables: azure.mgmt.sql.aio.operations.ManagedDatabaseTablesOperations :ivar managed_database_transparent_data_encryption: @@ -298,21 +380,29 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword 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_vulnerability_assessments: + ManagedDatabaseVulnerabilityAssessmentsOperations operations + :vartype managed_database_vulnerability_assessments: + azure.mgmt.sql.aio.operations.ManagedDatabaseVulnerabilityAssessmentsOperations + :ivar managed_databases: ManagedDatabasesOperations operations + :vartype managed_databases: azure.mgmt.sql.aio.operations.ManagedDatabasesOperations :ivar managed_instance_administrators: ManagedInstanceAdministratorsOperations operations :vartype managed_instance_administrators: azure.mgmt.sql.aio.operations.ManagedInstanceAdministratorsOperations + :ivar managed_instance_advanced_threat_protection_settings: + ManagedInstanceAdvancedThreatProtectionSettingsOperations operations + :vartype managed_instance_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations :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_dtcs: ManagedInstanceDtcsOperations operations + :vartype managed_instance_dtcs: azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations :ivar managed_instance_encryption_protectors: ManagedInstanceEncryptionProtectorsOperations operations :vartype managed_instance_encryption_protectors: @@ -341,26 +431,60 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword ManagedInstanceVulnerabilityAssessmentsOperations operations :vartype managed_instance_vulnerability_assessments: azure.mgmt.sql.aio.operations.ManagedInstanceVulnerabilityAssessmentsOperations + :ivar managed_instances: ManagedInstancesOperations operations + :vartype managed_instances: azure.mgmt.sql.aio.operations.ManagedInstancesOperations + :ivar managed_ledger_digest_uploads: ManagedLedgerDigestUploadsOperations operations + :vartype managed_ledger_digest_uploads: + azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations :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_dns_aliases: ManagedServerDnsAliasesOperations operations + :vartype managed_server_dns_aliases: + azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations :ivar managed_server_security_alert_policies: ManagedServerSecurityAlertPoliciesOperations operations :vartype managed_server_security_alert_policies: azure.mgmt.sql.aio.operations.ManagedServerSecurityAlertPoliciesOperations + :ivar network_security_perimeter_configurations: + NetworkSecurityPerimeterConfigurationsOperations operations + :vartype network_security_perimeter_configurations: + azure.mgmt.sql.aio.operations.NetworkSecurityPerimeterConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.sql.aio.operations.Operations + :ivar outbound_firewall_rules: OutboundFirewallRulesOperations operations + :vartype outbound_firewall_rules: azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :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_databases: RecoverableDatabasesOperations operations + :vartype recoverable_databases: azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations :ivar recoverable_managed_databases: RecoverableManagedDatabasesOperations operations :vartype recoverable_managed_databases: azure.mgmt.sql.aio.operations.RecoverableManagedDatabasesOperations + :ivar replication_links: ReplicationLinksOperations operations + :vartype replication_links: azure.mgmt.sql.aio.operations.ReplicationLinksOperations + :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 :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 + :ivar server_advanced_threat_protection_settings: + ServerAdvancedThreatProtectionSettingsOperations operations + :vartype server_advanced_threat_protection_settings: + azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations :ivar server_advisors: ServerAdvisorsOperations operations :vartype server_advisors: azure.mgmt.sql.aio.operations.ServerAdvisorsOperations :ivar server_automatic_tuning: ServerAutomaticTuningOperations operations @@ -372,6 +496,12 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword operations :vartype server_azure_ad_only_authentications: azure.mgmt.sql.aio.operations.ServerAzureADOnlyAuthenticationsOperations + :ivar server_configuration_options: ServerConfigurationOptionsOperations operations + :vartype server_configuration_options: + azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations + :ivar server_connection_policies: ServerConnectionPoliciesOperations operations + :vartype server_connection_policies: + azure.mgmt.sql.aio.operations.ServerConnectionPoliciesOperations :ivar server_dev_ops_audit_settings: ServerDevOpsAuditSettingsOperations operations :vartype server_dev_ops_audit_settings: azure.mgmt.sql.aio.operations.ServerDevOpsAuditSettingsOperations @@ -384,15 +514,62 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :ivar server_security_alert_policies: ServerSecurityAlertPoliciesOperations operations :vartype server_security_alert_policies: azure.mgmt.sql.aio.operations.ServerSecurityAlertPoliciesOperations + :ivar server_trust_certificates: ServerTrustCertificatesOperations operations + :vartype server_trust_certificates: + azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations :ivar server_trust_groups: ServerTrustGroupsOperations operations :vartype server_trust_groups: azure.mgmt.sql.aio.operations.ServerTrustGroupsOperations + :ivar server_usages: ServerUsagesOperations operations + :vartype server_usages: azure.mgmt.sql.aio.operations.ServerUsagesOperations :ivar server_vulnerability_assessments: ServerVulnerabilityAssessmentsOperations operations :vartype server_vulnerability_assessments: azure.mgmt.sql.aio.operations.ServerVulnerabilityAssessmentsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.sql.aio.operations.ServersOperations :ivar sql_agent: SqlAgentOperations operations :vartype sql_agent: azure.mgmt.sql.aio.operations.SqlAgentOperations + :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations + operations + :vartype sql_vulnerability_assessment_baseline: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations + :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations + operations + :vartype sql_vulnerability_assessment_baselines: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations + :ivar sql_vulnerability_assessment_execute_scan: + SqlVulnerabilityAssessmentExecuteScanOperations operations + :vartype sql_vulnerability_assessment_execute_scan: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations + :ivar sql_vulnerability_assessment_rule_baseline: + SqlVulnerabilityAssessmentRuleBaselineOperations operations + :vartype sql_vulnerability_assessment_rule_baseline: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations + :ivar sql_vulnerability_assessment_rule_baselines: + SqlVulnerabilityAssessmentRuleBaselinesOperations operations + :vartype sql_vulnerability_assessment_rule_baselines: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations + :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations + operations + :vartype sql_vulnerability_assessment_scan_result: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations + :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations + :vartype sql_vulnerability_assessment_scans: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations + :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations + operations + :vartype sql_vulnerability_assessments_settings: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations + :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations + :vartype sql_vulnerability_assessments: + azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations + :ivar start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations + operations + :vartype start_stop_managed_instance_schedules: + azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations :ivar subscription_usages: SubscriptionUsagesOperations operations :vartype subscription_usages: azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations + :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations + :vartype synapse_link_workspaces: azure.mgmt.sql.aio.operations.SynapseLinkWorkspacesOperations :ivar sync_agents: SyncAgentsOperations operations :vartype sync_agents: azure.mgmt.sql.aio.operations.SyncAgentsOperations :ivar sync_groups: SyncGroupsOperations operations @@ -403,208 +580,28 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :vartype tde_certificates: azure.mgmt.sql.aio.operations.TdeCertificatesOperations :ivar time_zones: TimeZonesOperations operations :vartype time_zones: azure.mgmt.sql.aio.operations.TimeZonesOperations + :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations + :vartype transparent_data_encryptions: + azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.sql.aio.operations.UsagesOperations + :ivar virtual_clusters: VirtualClustersOperations operations + :vartype virtual_clusters: azure.mgmt.sql.aio.operations.VirtualClustersOperations :ivar virtual_network_rules: VirtualNetworkRulesOperations operations :vartype virtual_network_rules: azure.mgmt.sql.aio.operations.VirtualNetworkRulesOperations :ivar workload_classifiers: WorkloadClassifiersOperations operations :vartype workload_classifiers: azure.mgmt.sql.aio.operations.WorkloadClassifiersOperations :ivar workload_groups: WorkloadGroupsOperations operations :vartype workload_groups: azure.mgmt.sql.aio.operations.WorkloadGroupsOperations - :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 - :vartype database_operations: azure.mgmt.sql.aio.operations.DatabaseOperationsOperations - :ivar database_usages: DatabaseUsagesOperations operations - :vartype database_usages: azure.mgmt.sql.aio.operations.DatabaseUsagesOperations - :ivar ledger_digest_uploads: LedgerDigestUploadsOperations operations - :vartype ledger_digest_uploads: azure.mgmt.sql.aio.operations.LedgerDigestUploadsOperations - :ivar outbound_firewall_rules: OutboundFirewallRulesOperations operations - :vartype outbound_firewall_rules: azure.mgmt.sql.aio.operations.OutboundFirewallRulesOperations - :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 - :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 - :ivar distributed_availability_groups: DistributedAvailabilityGroupsOperations operations - :vartype distributed_availability_groups: - azure.mgmt.sql.aio.operations.DistributedAvailabilityGroupsOperations - :ivar server_trust_certificates: ServerTrustCertificatesOperations operations - :vartype server_trust_certificates: - azure.mgmt.sql.aio.operations.ServerTrustCertificatesOperations - :ivar endpoint_certificates: EndpointCertificatesOperations operations - :vartype endpoint_certificates: azure.mgmt.sql.aio.operations.EndpointCertificatesOperations - :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 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 - :ivar server_blob_auditing_policies: ServerBlobAuditingPoliciesOperations operations - :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 - :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 database_advanced_threat_protection_settings: - DatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype database_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.DatabaseAdvancedThreatProtectionSettingsOperations - :ivar server_advanced_threat_protection_settings: - ServerAdvancedThreatProtectionSettingsOperations operations - :vartype server_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.ServerAdvancedThreatProtectionSettingsOperations - :ivar managed_server_dns_aliases: ManagedServerDnsAliasesOperations operations - :vartype managed_server_dns_aliases: - azure.mgmt.sql.aio.operations.ManagedServerDnsAliasesOperations - :ivar managed_database_advanced_threat_protection_settings: - ManagedDatabaseAdvancedThreatProtectionSettingsOperations operations - :vartype managed_database_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.ManagedDatabaseAdvancedThreatProtectionSettingsOperations - :ivar managed_instance_advanced_threat_protection_settings: - ManagedInstanceAdvancedThreatProtectionSettingsOperations operations - :vartype managed_instance_advanced_threat_protection_settings: - azure.mgmt.sql.aio.operations.ManagedInstanceAdvancedThreatProtectionSettingsOperations - :ivar replication_links: ReplicationLinksOperations operations - :vartype replication_links: azure.mgmt.sql.aio.operations.ReplicationLinksOperations - :ivar managed_database_move_operations: ManagedDatabaseMoveOperationsOperations operations - :vartype managed_database_move_operations: - azure.mgmt.sql.aio.operations.ManagedDatabaseMoveOperationsOperations - :ivar managed_instance_dtcs: ManagedInstanceDtcsOperations operations - :vartype managed_instance_dtcs: azure.mgmt.sql.aio.operations.ManagedInstanceDtcsOperations - :ivar synapse_link_workspaces: SynapseLinkWorkspacesOperations operations - :vartype synapse_link_workspaces: azure.mgmt.sql.aio.operations.SynapseLinkWorkspacesOperations - :ivar virtual_clusters: VirtualClustersOperations operations - :vartype virtual_clusters: azure.mgmt.sql.aio.operations.VirtualClustersOperations - :ivar instance_failover_groups: InstanceFailoverGroupsOperations operations - :vartype instance_failover_groups: - azure.mgmt.sql.aio.operations.InstanceFailoverGroupsOperations - :ivar managed_database_restore_details: ManagedDatabaseRestoreDetailsOperations operations - :vartype managed_database_restore_details: - azure.mgmt.sql.aio.operations.ManagedDatabaseRestoreDetailsOperations - :ivar database_encryption_protectors: DatabaseEncryptionProtectorsOperations operations - :vartype database_encryption_protectors: - azure.mgmt.sql.aio.operations.DatabaseEncryptionProtectorsOperations - :ivar managed_databases: ManagedDatabasesOperations operations - :vartype managed_databases: azure.mgmt.sql.aio.operations.ManagedDatabasesOperations - :ivar managed_instances: ManagedInstancesOperations operations - :vartype managed_instances: azure.mgmt.sql.aio.operations.ManagedInstancesOperations - :ivar managed_ledger_digest_uploads: ManagedLedgerDigestUploadsOperations operations - :vartype managed_ledger_digest_uploads: - azure.mgmt.sql.aio.operations.ManagedLedgerDigestUploadsOperations - :ivar recoverable_databases: RecoverableDatabasesOperations operations - :vartype recoverable_databases: azure.mgmt.sql.aio.operations.RecoverableDatabasesOperations - :ivar restorable_dropped_databases: RestorableDroppedDatabasesOperations operations - :vartype restorable_dropped_databases: - azure.mgmt.sql.aio.operations.RestorableDroppedDatabasesOperations - :ivar server_configuration_options: ServerConfigurationOptionsOperations operations - :vartype server_configuration_options: - azure.mgmt.sql.aio.operations.ServerConfigurationOptionsOperations - :ivar servers: ServersOperations operations - :vartype servers: azure.mgmt.sql.aio.operations.ServersOperations - :ivar start_stop_managed_instance_schedules: StartStopManagedInstanceSchedulesOperations - operations - :vartype start_stop_managed_instance_schedules: - azure.mgmt.sql.aio.operations.StartStopManagedInstanceSchedulesOperations - :ivar transparent_data_encryptions: TransparentDataEncryptionsOperations operations - :vartype transparent_data_encryptions: - azure.mgmt.sql.aio.operations.TransparentDataEncryptionsOperations - :ivar failover_groups: FailoverGroupsOperations operations - :vartype failover_groups: azure.mgmt.sql.aio.operations.FailoverGroupsOperations - :ivar ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations - :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations - operations - :vartype sql_vulnerability_assessment_baseline: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselineOperations - :ivar sql_vulnerability_assessment_baselines: SqlVulnerabilityAssessmentBaselinesOperations - operations - :vartype sql_vulnerability_assessment_baselines: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentBaselinesOperations - :ivar sql_vulnerability_assessment_execute_scan: - SqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentExecuteScanOperations - :ivar sql_vulnerability_assessment_rule_baseline: - SqlVulnerabilityAssessmentRuleBaselineOperations operations - :vartype sql_vulnerability_assessment_rule_baseline: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselineOperations - :ivar sql_vulnerability_assessment_rule_baselines: - SqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar sql_vulnerability_assessment_scan_result: SqlVulnerabilityAssessmentScanResultOperations - operations - :vartype sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScanResultOperations - :ivar sql_vulnerability_assessment_scans: SqlVulnerabilityAssessmentScansOperations operations - :vartype sql_vulnerability_assessment_scans: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentScansOperations - :ivar sql_vulnerability_assessments_settings: SqlVulnerabilityAssessmentsSettingsOperations - operations - :vartype sql_vulnerability_assessments_settings: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsSettingsOperations - :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations - :vartype sql_vulnerability_assessments: - azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations - :ivar database_sql_vulnerability_assessment_baselines: - DatabaseSqlVulnerabilityAssessmentBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_baselines: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentBaselinesOperations - :ivar database_sql_vulnerability_assessment_execute_scan: - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations operations - :vartype database_sql_vulnerability_assessment_execute_scan: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentExecuteScanOperations - :ivar database_sql_vulnerability_assessment_rule_baselines: - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations operations - :vartype database_sql_vulnerability_assessment_rule_baselines: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations - :ivar database_sql_vulnerability_assessment_scan_result: - DatabaseSqlVulnerabilityAssessmentScanResultOperations operations - :vartype database_sql_vulnerability_assessment_scan_result: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScanResultOperations - :ivar database_sql_vulnerability_assessment_scans: - DatabaseSqlVulnerabilityAssessmentScansOperations operations - :vartype database_sql_vulnerability_assessment_scans: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentScansOperations - :ivar database_sql_vulnerability_assessments_settings: - DatabaseSqlVulnerabilityAssessmentsSettingsOperations operations - :vartype database_sql_vulnerability_assessments_settings: - azure.mgmt.sql.aio.operations.DatabaseSqlVulnerabilityAssessmentsSettingsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription ID that identifies an Azure subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -625,360 +622,346 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_masking_policies = DataMaskingPoliciesOperations( + self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_masking_rules = DataMaskingRulesOperations( + self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.geo_backup_policies = GeoBackupPoliciesOperations( + self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( 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.server_communication_links = ServerCommunicationLinksOperations( + self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service_objectives = ServiceObjectivesOperations( + self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( + self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( + self.data_masking_rules = DataMaskingRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_advisors = DatabaseAdvisorsOperations( + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_automatic_tuning = DatabaseAutomaticTuningOperations( + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_columns = DatabaseColumnsOperations( + self.database_advisors = DatabaseAdvisorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_recommended_actions = DatabaseRecommendedActionsOperations( + self.database_automatic_tuning = DatabaseAutomaticTuningOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_schemas = DatabaseSchemasOperations( + self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( 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.database_extensions = DatabaseExtensionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( + self.database_operations = DatabaseOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + self.database_schemas = DatabaseSchemasOperations( 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.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.encryption_protectors = EncryptionProtectorsOperations( + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.firewall_rules = FirewallRulesOperations(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.database_sql_vulnerability_assessment_execute_scan = ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( + 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.database_sql_vulnerability_assessment_rule_baselines = ( + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.job_target_groups = JobTargetGroupsOperations( + self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( 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.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_window_options = MaintenanceWindowOptionsOperations( + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.maintenance_windows = MaintenanceWindowsOperations( + self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_usages = DatabaseUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( + self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_columns = ManagedDatabaseColumnsOperations( + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_queries = ManagedDatabaseQueriesOperations( + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_schemas = ManagedDatabaseSchemasOperations( + self.elastic_pool_operations = ElasticPoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( + self.elastic_pools = ElasticPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_protectors = EncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( + self.endpoint_certificates = EndpointCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_tables = ManagedDatabaseTablesOperations( + 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.geo_backup_policies = GeoBackupPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( 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.instance_failover_groups = InstanceFailoverGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + 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.job_private_endpoints = JobPrivateEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( + self.job_step_executions = JobStepExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( + 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.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( + self.job_target_groups = JobTargetGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_keys = ManagedInstanceKeysOperations( + self.job_versions = JobVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.ledger_digest_uploads = LedgerDigestUploadsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( + self.capabilities = CapabilitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.long_term_retention_backups = LongTermRetentionBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_operations = ManagedInstanceOperationsOperations( + self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( + self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( + self.maintenance_window_options = MaintenanceWindowOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( + self.maintenance_windows = MaintenanceWindowsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( + self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self.managed_database_advanced_threat_protection_settings = ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations( 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.managed_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_link_resources = PrivateLinkResourcesOperations( + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( + self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restore_points = RestorePointsOperations(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.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( + self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( + self.managed_database_security_alert_policies = ManagedDatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( + self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_dns_aliases = ServerDnsAliasesOperations( + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( 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.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_groups = ServerTrustGroupsOperations( + self.managed_database_transparent_data_encryption = ManagedDatabaseTransparentDataEncryptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - 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.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( 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.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_groups = WorkloadGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.backup_short_term_retention_policies = BackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self.managed_instance_advanced_threat_protection_settings = ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.database_extensions = DatabaseExtensionsOperations( + self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( 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.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_firewall_rules = OutboundFirewallRulesOperations( + self.managed_instance_keys = ManagedInstanceKeysOperations( 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.managed_instance_long_term_retention_policies = ManagedInstanceLongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self.managed_instance_operations = ManagedInstanceOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.managed_instance_private_endpoint_connections = ManagedInstancePrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.managed_instance_private_link_resources = ManagedInstancePrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.managed_instance_tde_certificates = ManagedInstanceTdeCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( 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_restorable_dropped_database_backup_short_term_retention_policies = ( + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.sensitivity_labels = SensitivityLabelsOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( + self.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_firewall_rules = OutboundFirewallRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_advanced_threat_protection_settings = ( - ManagedDatabaseAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_instance_advanced_threat_protection_settings = ( - ManagedInstanceAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.replication_links = ReplicationLinksOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + 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.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( + self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + 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.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instances = ManagedInstancesOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + 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_configuration_options = ServerConfigurationOptionsOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -1006,28 +989,36 @@ def __init__( self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_execute_scan = ( - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.subscription_usages = SubscriptionUsagesOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_rule_baselines = ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + 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.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) + self.transparent_data_encryptions = TransparentDataEncryptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.usages = UsagesOperations(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) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/__init__.py index b4dafd81fe63..810288a09bc3 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 @@ -6,66 +6,110 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations +from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations +from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations +from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations +from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations from ._data_masking_policies_operations import DataMaskingPoliciesOperations from ._data_masking_rules_operations import DataMaskingRulesOperations -from ._geo_backup_policies_operations import GeoBackupPoliciesOperations -from ._databases_operations import DatabasesOperations -from ._elastic_pools_operations import ElasticPoolsOperations -from ._server_communication_links_operations import ServerCommunicationLinksOperations -from ._service_objectives_operations import ServiceObjectivesOperations -from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations -from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations -from ._server_usages_operations import ServerUsagesOperations +from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations +from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations from ._database_advisors_operations import DatabaseAdvisorsOperations from ._database_automatic_tuning_operations import DatabaseAutomaticTuningOperations from ._database_columns_operations import DatabaseColumnsOperations +from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations +from ._database_extensions_operations import DatabaseExtensionsOperations +from ._database_operations_operations import DatabaseOperationsOperations from ._database_recommended_actions_operations import DatabaseRecommendedActionsOperations from ._database_schemas_operations import DatabaseSchemasOperations from ._database_security_alert_policies_operations import DatabaseSecurityAlertPoliciesOperations +from ._database_sql_vulnerability_assessment_baselines_operations import ( + DatabaseSqlVulnerabilityAssessmentBaselinesOperations, +) +from ._database_sql_vulnerability_assessment_execute_scan_operations import ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations, +) +from ._database_sql_vulnerability_assessment_rule_baselines_operations import ( + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations, +) +from ._database_sql_vulnerability_assessment_scan_result_operations import ( + DatabaseSqlVulnerabilityAssessmentScanResultOperations, +) +from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations +from ._database_sql_vulnerability_assessments_settings_operations import ( + DatabaseSqlVulnerabilityAssessmentsSettingsOperations, +) from ._database_tables_operations import DatabaseTablesOperations +from ._database_usages_operations import DatabaseUsagesOperations from ._database_vulnerability_assessment_rule_baselines_operations import ( DatabaseVulnerabilityAssessmentRuleBaselinesOperations, ) -from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations from ._database_vulnerability_assessment_scans_operations import DatabaseVulnerabilityAssessmentScansOperations -from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations +from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations +from ._databases_operations import DatabasesOperations from ._deleted_servers_operations import DeletedServersOperations +from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations from ._elastic_pool_operations_operations import ElasticPoolOperationsOperations +from ._elastic_pools_operations import ElasticPoolsOperations from ._encryption_protectors_operations import EncryptionProtectorsOperations +from ._endpoint_certificates_operations import EndpointCertificatesOperations +from ._failover_groups_operations import FailoverGroupsOperations from ._firewall_rules_operations import FirewallRulesOperations +from ._geo_backup_policies_operations import GeoBackupPoliciesOperations +from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations +from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations from ._instance_pools_operations import InstancePoolsOperations from ._job_agents_operations import JobAgentsOperations from ._job_credentials_operations import JobCredentialsOperations from ._job_executions_operations import JobExecutionsOperations -from ._jobs_operations import JobsOperations +from ._job_private_endpoints_operations import JobPrivateEndpointsOperations from ._job_step_executions_operations import JobStepExecutionsOperations from ._job_steps_operations import JobStepsOperations from ._job_target_executions_operations import JobTargetExecutionsOperations from ._job_target_groups_operations import JobTargetGroupsOperations from ._job_versions_operations import JobVersionsOperations +from ._jobs_operations import JobsOperations +from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations from ._capabilities_operations import CapabilitiesOperations +from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations +from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations from ._long_term_retention_policies_operations import LongTermRetentionPoliciesOperations from ._maintenance_window_options_operations import MaintenanceWindowOptionsOperations from ._maintenance_windows_operations import MaintenanceWindowsOperations from ._managed_backup_short_term_retention_policies_operations import ManagedBackupShortTermRetentionPoliciesOperations +from ._managed_database_advanced_threat_protection_settings_operations import ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations, +) from ._managed_database_columns_operations import ManagedDatabaseColumnsOperations +from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations from ._managed_database_queries_operations import ManagedDatabaseQueriesOperations +from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations from ._managed_database_schemas_operations import ManagedDatabaseSchemasOperations from ._managed_database_security_alert_policies_operations import ManagedDatabaseSecurityAlertPoliciesOperations from ._managed_database_security_events_operations import ManagedDatabaseSecurityEventsOperations +from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations +from ._managed_database_recommended_sensitivity_labels_operations import ( + ManagedDatabaseRecommendedSensitivityLabelsOperations, +) from ._managed_database_tables_operations import ManagedDatabaseTablesOperations from ._managed_database_transparent_data_encryption_operations import ManagedDatabaseTransparentDataEncryptionOperations from ._managed_database_vulnerability_assessment_rule_baselines_operations import ( ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ) -from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations from ._managed_database_vulnerability_assessment_scans_operations import ( ManagedDatabaseVulnerabilityAssessmentScansOperations, ) +from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations +from ._managed_databases_operations import ManagedDatabasesOperations from ._managed_instance_administrators_operations import ManagedInstanceAdministratorsOperations +from ._managed_instance_advanced_threat_protection_settings_operations import ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations, +) from ._managed_instance_azure_ad_only_authentications_operations import ( ManagedInstanceAzureADOnlyAuthenticationsOperations, ) +from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations from ._managed_instance_encryption_protectors_operations import ManagedInstanceEncryptionProtectorsOperations from ._managed_instance_keys_operations import ManagedInstanceKeysOperations from ._managed_instance_long_term_retention_policies_operations import ( @@ -78,88 +122,44 @@ from ._managed_instance_private_link_resources_operations import ManagedInstancePrivateLinkResourcesOperations from ._managed_instance_tde_certificates_operations import ManagedInstanceTdeCertificatesOperations from ._managed_instance_vulnerability_assessments_operations import ManagedInstanceVulnerabilityAssessmentsOperations +from ._managed_instances_operations import ManagedInstancesOperations +from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ( ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ) +from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations from ._operations import Operations +from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._recoverable_databases_operations import RecoverableDatabasesOperations from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations +from ._replication_links_operations import ReplicationLinksOperations +from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations +from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._restore_points_operations import RestorePointsOperations +from ._sensitivity_labels_operations import SensitivityLabelsOperations +from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations +from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations from ._server_advisors_operations import ServerAdvisorsOperations from ._server_automatic_tuning_operations import ServerAutomaticTuningOperations from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations +from ._server_configuration_options_operations import ServerConfigurationOptionsOperations +from ._server_connection_policies_operations import ServerConnectionPoliciesOperations from ._server_dev_ops_audit_settings_operations import ServerDevOpsAuditSettingsOperations from ._server_dns_aliases_operations import ServerDnsAliasesOperations from ._server_keys_operations import ServerKeysOperations from ._server_operations_operations import ServerOperationsOperations from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations +from ._server_trust_certificates_operations import ServerTrustCertificatesOperations from ._server_trust_groups_operations import ServerTrustGroupsOperations +from ._server_usages_operations import ServerUsagesOperations from ._server_vulnerability_assessments_operations import ServerVulnerabilityAssessmentsOperations -from ._sql_agent_operations import SqlAgentOperations -from ._subscription_usages_operations import SubscriptionUsagesOperations -from ._sync_agents_operations import SyncAgentsOperations -from ._sync_groups_operations import SyncGroupsOperations -from ._sync_members_operations import SyncMembersOperations -from ._tde_certificates_operations import TdeCertificatesOperations -from ._time_zones_operations import TimeZonesOperations -from ._virtual_network_rules_operations import VirtualNetworkRulesOperations -from ._workload_classifiers_operations import WorkloadClassifiersOperations -from ._workload_groups_operations import WorkloadGroupsOperations -from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations -from ._database_extensions_operations import DatabaseExtensionsOperations -from ._database_operations_operations import DatabaseOperationsOperations -from ._database_usages_operations import DatabaseUsagesOperations -from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations -from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations -from ._usages_operations import UsagesOperations -from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations -from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations -from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations -from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations -from ._server_trust_certificates_operations import ServerTrustCertificatesOperations -from ._endpoint_certificates_operations import EndpointCertificatesOperations -from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations -from ._managed_database_recommended_sensitivity_labels_operations import ( - ManagedDatabaseRecommendedSensitivityLabelsOperations, -) -from ._sensitivity_labels_operations import SensitivityLabelsOperations -from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations -from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations -from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations -from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations -from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations -from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations -from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations -from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations -from ._managed_database_advanced_threat_protection_settings_operations import ( - ManagedDatabaseAdvancedThreatProtectionSettingsOperations, -) -from ._managed_instance_advanced_threat_protection_settings_operations import ( - ManagedInstanceAdvancedThreatProtectionSettingsOperations, -) -from ._replication_links_operations import ReplicationLinksOperations -from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations -from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations -from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations -from ._virtual_clusters_operations import VirtualClustersOperations -from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations -from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations -from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations -from ._managed_databases_operations import ManagedDatabasesOperations -from ._managed_instances_operations import ManagedInstancesOperations -from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations -from ._recoverable_databases_operations import RecoverableDatabasesOperations -from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations -from ._server_configuration_options_operations import ServerConfigurationOptionsOperations from ._servers_operations import ServersOperations -from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations -from ._failover_groups_operations import FailoverGroupsOperations -from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations +from ._sql_agent_operations import SqlAgentOperations from ._sql_vulnerability_assessment_baseline_operations import SqlVulnerabilityAssessmentBaselineOperations from ._sql_vulnerability_assessment_baselines_operations import SqlVulnerabilityAssessmentBaselinesOperations from ._sql_vulnerability_assessment_execute_scan_operations import SqlVulnerabilityAssessmentExecuteScanOperations @@ -169,80 +169,106 @@ from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations from ._sql_vulnerability_assessments_settings_operations import SqlVulnerabilityAssessmentsSettingsOperations from ._sql_vulnerability_assessments_operations import SqlVulnerabilityAssessmentsOperations -from ._database_sql_vulnerability_assessment_baselines_operations import ( - DatabaseSqlVulnerabilityAssessmentBaselinesOperations, -) -from ._database_sql_vulnerability_assessment_execute_scan_operations import ( - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations, -) -from ._database_sql_vulnerability_assessment_rule_baselines_operations import ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations, -) -from ._database_sql_vulnerability_assessment_scan_result_operations import ( - DatabaseSqlVulnerabilityAssessmentScanResultOperations, -) -from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations -from ._database_sql_vulnerability_assessments_settings_operations import ( - DatabaseSqlVulnerabilityAssessmentsSettingsOperations, -) +from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations +from ._subscription_usages_operations import SubscriptionUsagesOperations +from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations +from ._sync_agents_operations import SyncAgentsOperations +from ._sync_groups_operations import SyncGroupsOperations +from ._sync_members_operations import SyncMembersOperations +from ._tde_certificates_operations import TdeCertificatesOperations +from ._time_zones_operations import TimeZonesOperations +from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations +from ._usages_operations import UsagesOperations +from ._virtual_clusters_operations import VirtualClustersOperations +from ._virtual_network_rules_operations import VirtualNetworkRulesOperations +from ._workload_classifiers_operations import WorkloadClassifiersOperations +from ._workload_groups_operations import WorkloadGroupsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "BackupShortTermRetentionPoliciesOperations", + "ServerBlobAuditingPoliciesOperations", + "DatabaseBlobAuditingPoliciesOperations", + "ExtendedDatabaseBlobAuditingPoliciesOperations", + "ExtendedServerBlobAuditingPoliciesOperations", "DataMaskingPoliciesOperations", "DataMaskingRulesOperations", - "GeoBackupPoliciesOperations", - "DatabasesOperations", - "ElasticPoolsOperations", - "ServerCommunicationLinksOperations", - "ServiceObjectivesOperations", - "ElasticPoolActivitiesOperations", - "ElasticPoolDatabaseActivitiesOperations", - "ServerUsagesOperations", + "DataWarehouseUserActivitiesOperations", + "DatabaseAdvancedThreatProtectionSettingsOperations", "DatabaseAdvisorsOperations", "DatabaseAutomaticTuningOperations", "DatabaseColumnsOperations", + "DatabaseEncryptionProtectorsOperations", + "DatabaseExtensionsOperations", + "DatabaseOperationsOperations", "DatabaseRecommendedActionsOperations", "DatabaseSchemasOperations", "DatabaseSecurityAlertPoliciesOperations", + "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", + "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentScanResultOperations", + "DatabaseSqlVulnerabilityAssessmentScansOperations", + "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", "DatabaseTablesOperations", + "DatabaseUsagesOperations", "DatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseVulnerabilityAssessmentsOperations", "DatabaseVulnerabilityAssessmentScansOperations", - "DataWarehouseUserActivitiesOperations", + "DatabaseVulnerabilityAssessmentsOperations", + "DatabasesOperations", "DeletedServersOperations", + "DistributedAvailabilityGroupsOperations", "ElasticPoolOperationsOperations", + "ElasticPoolsOperations", "EncryptionProtectorsOperations", + "EndpointCertificatesOperations", + "FailoverGroupsOperations", "FirewallRulesOperations", + "GeoBackupPoliciesOperations", + "IPv6FirewallRulesOperations", + "InstanceFailoverGroupsOperations", "InstancePoolsOperations", "JobAgentsOperations", "JobCredentialsOperations", "JobExecutionsOperations", - "JobsOperations", + "JobPrivateEndpointsOperations", "JobStepExecutionsOperations", "JobStepsOperations", "JobTargetExecutionsOperations", "JobTargetGroupsOperations", "JobVersionsOperations", + "JobsOperations", + "LedgerDigestUploadsOperations", "CapabilitiesOperations", + "LongTermRetentionBackupsOperations", + "LongTermRetentionManagedInstanceBackupsOperations", "LongTermRetentionPoliciesOperations", "MaintenanceWindowOptionsOperations", "MaintenanceWindowsOperations", "ManagedBackupShortTermRetentionPoliciesOperations", + "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", "ManagedDatabaseColumnsOperations", + "ManagedDatabaseMoveOperationsOperations", "ManagedDatabaseQueriesOperations", + "ManagedDatabaseRestoreDetailsOperations", "ManagedDatabaseSchemasOperations", "ManagedDatabaseSecurityAlertPoliciesOperations", "ManagedDatabaseSecurityEventsOperations", + "ManagedDatabaseSensitivityLabelsOperations", + "ManagedDatabaseRecommendedSensitivityLabelsOperations", "ManagedDatabaseTablesOperations", "ManagedDatabaseTransparentDataEncryptionOperations", "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "ManagedDatabaseVulnerabilityAssessmentsOperations", "ManagedDatabaseVulnerabilityAssessmentScansOperations", + "ManagedDatabaseVulnerabilityAssessmentsOperations", + "ManagedDatabasesOperations", "ManagedInstanceAdministratorsOperations", + "ManagedInstanceAdvancedThreatProtectionSettingsOperations", "ManagedInstanceAzureADOnlyAuthenticationsOperations", + "ManagedInstanceDtcsOperations", "ManagedInstanceEncryptionProtectorsOperations", "ManagedInstanceKeysOperations", "ManagedInstanceLongTermRetentionPoliciesOperations", @@ -251,80 +277,42 @@ "ManagedInstancePrivateLinkResourcesOperations", "ManagedInstanceTdeCertificatesOperations", "ManagedInstanceVulnerabilityAssessmentsOperations", + "ManagedInstancesOperations", + "ManagedLedgerDigestUploadsOperations", "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", + "ManagedServerDnsAliasesOperations", "ManagedServerSecurityAlertPoliciesOperations", + "NetworkSecurityPerimeterConfigurationsOperations", "Operations", + "OutboundFirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "RecoverableDatabasesOperations", "RecoverableManagedDatabasesOperations", + "ReplicationLinksOperations", + "RestorableDroppedDatabasesOperations", + "RestorableDroppedManagedDatabasesOperations", "RestorePointsOperations", + "SensitivityLabelsOperations", + "RecommendedSensitivityLabelsOperations", + "ServerAdvancedThreatProtectionSettingsOperations", "ServerAdvisorsOperations", "ServerAutomaticTuningOperations", "ServerAzureADAdministratorsOperations", "ServerAzureADOnlyAuthenticationsOperations", + "ServerConfigurationOptionsOperations", + "ServerConnectionPoliciesOperations", "ServerDevOpsAuditSettingsOperations", "ServerDnsAliasesOperations", "ServerKeysOperations", "ServerOperationsOperations", "ServerSecurityAlertPoliciesOperations", + "ServerTrustCertificatesOperations", "ServerTrustGroupsOperations", + "ServerUsagesOperations", "ServerVulnerabilityAssessmentsOperations", - "SqlAgentOperations", - "SubscriptionUsagesOperations", - "SyncAgentsOperations", - "SyncGroupsOperations", - "SyncMembersOperations", - "TdeCertificatesOperations", - "TimeZonesOperations", - "VirtualNetworkRulesOperations", - "WorkloadClassifiersOperations", - "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseOperationsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "DistributedAvailabilityGroupsOperations", - "ServerTrustCertificatesOperations", - "EndpointCertificatesOperations", - "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", - "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", - "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", - "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", - "ReplicationLinksOperations", - "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", - "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", - "ManagedInstancesOperations", - "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", "ServersOperations", - "StartStopManagedInstanceSchedulesOperations", - "TransparentDataEncryptionsOperations", - "FailoverGroupsOperations", - "IPv6FirewallRulesOperations", + "SqlAgentOperations", "SqlVulnerabilityAssessmentBaselineOperations", "SqlVulnerabilityAssessmentBaselinesOperations", "SqlVulnerabilityAssessmentExecuteScanOperations", @@ -334,12 +322,20 @@ "SqlVulnerabilityAssessmentScansOperations", "SqlVulnerabilityAssessmentsSettingsOperations", "SqlVulnerabilityAssessmentsOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", + "StartStopManagedInstanceSchedulesOperations", + "SubscriptionUsagesOperations", + "SynapseLinkWorkspacesOperations", + "SyncAgentsOperations", + "SyncGroupsOperations", + "SyncMembersOperations", + "TdeCertificatesOperations", + "TimeZonesOperations", + "TransparentDataEncryptionsOperations", + "UsagesOperations", + "VirtualClustersOperations", + "VirtualNetworkRulesOperations", + "WorkloadClassifiersOperations", + "WorkloadGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() 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 baf5f276a299..8d9b333f4fc9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 BackupShortTermRetentionPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies" + } + @distributed_trace_async async def get( self, @@ -96,7 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +252,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -338,7 +435,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -405,7 +502,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -588,7 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -634,88 +731,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 BackupShortTermRetentionPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies" - } 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 79f1afce31cd..2173b3e7ae5d 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 @@ -60,8 +60,8 @@ async def list_by_location( :type location_name: str :param include: If specified, restricts the response to only include the selected item. Known values are: "supportedEditions", "supportedElasticPoolEditions", - "supportedManagedInstanceVersions", "supportedInstancePoolEditions", and - "supportedManagedInstanceEditions". Default value is None. + "supportedManagedInstanceVersions", "supportedInstancePoolEditions", + "supportedManagedInstanceEditions", and "supportedJobAgentVersions". Default value is None. :type include: str or ~azure.mgmt.sql.models.CapabilityGroup :keyword callable cls: A custom type or function that will be passed the direct response :return: LocationCapabilities or the result of cls(response) @@ -79,7 +79,7 @@ async def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) request = build_list_by_location_request( 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 1bd8b41cc31b..c6ef2c94534b 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 @@ -7,7 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._data_masking_policies_operations import build_create_or_update_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,12 +51,89 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Gets the database data masking policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataMaskingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_policy_name=data_masking_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DataMaskingPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" + } + @overload async def create_or_update( self, resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: _models.DataMaskingPolicy, *, content_type: str = "application/json", @@ -76,15 +148,14 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy @@ -97,6 +168,7 @@ async def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: IO, *, content_type: str = "application/json", @@ -111,15 +183,14 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy @@ -132,6 +203,7 @@ async def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: Union[_models.DataMaskingPolicy, IO], **kwargs: Any ) -> _models.DataMaskingPolicy: @@ -144,13 +216,12 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Is either a DataMaskingPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or IO - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -170,8 +241,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) @@ -187,9 +257,9 @@ async def create_or_update( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + data_masking_policy_name=data_masking_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, content=_content, @@ -207,90 +277,21 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } + if response.status_code == 200: + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) - @distributed_trace_async - async def get( - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("DataMaskingPolicy", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { + create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" } 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 3b244ac23c73..f9619b8bc004 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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -31,10 +31,6 @@ from ..._vendor import _convert_request from ...operations._data_masking_rules_operations import build_create_or_update_request, build_list_by_database_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,12 +54,116 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + **kwargs: Any + ) -> AsyncIterable["_models.DataMaskingRule"]: + """Gets a list of database data masking 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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking rule + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataMaskingRule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_policy_name=data_masking_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" + } + @overload async def create_or_update( self, resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: _models.DataMaskingRule, *, @@ -79,6 +179,9 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. @@ -87,10 +190,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingRule @@ -103,6 +202,7 @@ async def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: IO, *, @@ -118,6 +218,9 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. @@ -126,10 +229,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingRule @@ -142,6 +241,7 @@ async def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: Union[_models.DataMaskingRule, IO], **kwargs: Any @@ -155,15 +255,14 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. Is either a DataMaskingRule type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or IO - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -183,8 +282,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) @@ -200,10 +298,10 @@ async def create_or_update( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + data_masking_policy_name=data_masking_policy_name, data_masking_rule_name=data_masking_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, content=_content, @@ -239,92 +337,3 @@ async def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataMaskingRule"]: - """Gets a list of database data masking 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataMaskingRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DataMaskingRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" - } 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 0191b59a7f49..0d0610be666c 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -52,83 +53,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param data_warehouse_user_activity_name: The activity name of the data warehouse. "current" - Required. - :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 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("DataWarehouseUserActivities", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" - } - @distributed_trace def list_by_database( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -152,7 +76,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataWarehouseUserActivitiesListResult] = kwargs.pop("cls", None) error_map = { @@ -180,7 +104,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -213,3 +148,80 @@ async def get_next(next_link=None): list_by_database.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities" } + + @distributed_trace_async + async def get( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_warehouse_user_activity_name: The activity name of the data warehouse. "current" + Required. + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DataWarehouseUserActivities", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" + } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py index 7ae70f7855ad..57fbdb1fb997 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -180,7 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -336,7 +348,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) 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 a17af91695e9..1789055ee009 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 @@ -91,7 +91,7 @@ async def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) request = build_list_by_database_request( @@ -161,7 +161,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) request = build_get_request( @@ -311,7 +311,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) 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 5e1d2ae01f0c..11cd2e8b40b5 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 @@ -80,7 +80,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) request = build_get_request( @@ -220,7 +220,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) 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 894f864b97f6..6bfbeb4bab64 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -113,7 +114,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -180,7 +192,7 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -331,7 +343,7 @@ async def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) 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 eb69b69d75a8..f66f400f87cd 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -97,7 +98,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -130,7 +131,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -199,7 +211,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -230,7 +242,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -306,7 +329,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py index 42cd2d9ffc49..2d0d017f5e18 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_encryption_protectors_operations.py @@ -71,7 +71,7 @@ async def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revalidate_request( @@ -142,7 +142,7 @@ async def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -205,7 +205,7 @@ async def _revert_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revert_request( @@ -276,7 +276,7 @@ async def begin_revert( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 660949643072..24ab7b072db8 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,6 +60,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ImportExportExtensionsOperationResult"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 ImportExportExtensionsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions" + } + @distributed_trace_async async def get( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, database_name: str, extension_name: str, **kwargs: Any @@ -90,7 +187,7 @@ async def get( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_get_request( @@ -145,7 +242,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportExtensionsOperationResult]] = kwargs.pop("cls", None) @@ -210,7 +307,8 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -253,7 +351,8 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -294,7 +393,8 @@ async def begin_create_or_update( parameters: Union[_models.DatabaseExtensions, IO], **kwargs: Any ) -> AsyncLROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -328,7 +428,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportExtensionsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -374,88 +474,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportExportExtensionsOperationResult"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 ImportExportExtensionsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions" - } 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 0e946b0600c4..ff0b4bacb0bd 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -52,72 +53,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param operation_id: The operation identifier. Required. - :type operation_id: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel" - } - @distributed_trace def list_by_database( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -139,7 +74,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -167,7 +102,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -200,3 +146,69 @@ async def get_next(next_link=None): list_by_database.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations" } + + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param operation_id: The operation identifier. Required. + :type operation_id: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel" + } 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 ab5d79c35796..451b4be5896d 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 @@ -86,7 +86,7 @@ async def list_by_database_advisor( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) request = build_list_by_database_advisor_request( @@ -164,7 +164,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) request = build_get_request( @@ -324,7 +324,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) 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 82025cd4a25f..8b7c31fa24d2 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) error_map = { @@ -110,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) request = build_get_request( 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 e565d0de814c..826ef64a066c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -57,6 +58,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabaseSecurityAlertPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database for which the security alert policy is defined. + Required. + :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 DatabaseSecurityAlertPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies" + } + @distributed_trace_async async def get( self, @@ -76,7 +174,7 @@ async def get( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: DatabaseSecurityAlertPolicy or the result of cls(response) @@ -94,7 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +253,7 @@ async def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy @@ -190,7 +288,7 @@ async def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: IO @@ -223,7 +321,7 @@ async def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Is either a DatabaseSecurityAlertPolicy type or a IO type. Required. @@ -247,7 +345,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) @@ -301,89 +399,3 @@ async def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DatabaseSecurityAlertPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database for which the security alert policy is defined. - Required. - :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 DatabaseSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py index 1eadef8bd489..7b41a57be6ee 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_baselines_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -88,7 +89,7 @@ def list_by_sql_vulnerability_assessment( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -117,7 +118,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -193,7 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( @@ -358,7 +370,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py index 0f59df266e73..88f4a6b1d7ac 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py @@ -71,7 +71,7 @@ async def _execute_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_execute_request( @@ -142,7 +142,7 @@ async def begin_execute( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py index 4b0bccf6978f..7413901717ca 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -92,7 +93,7 @@ def list_by_baseline( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -122,7 +123,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -201,7 +213,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -375,7 +387,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -471,7 +483,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py index 4e67ac0cc349..7fc60057a351 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scan_result_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -91,7 +92,7 @@ def list_by_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -121,7 +122,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -200,7 +212,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py index f93531d3c137..99fe917fdb1b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessment_scans_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -86,7 +87,7 @@ def list_by_sql_vulnerability_assessments( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -115,7 +116,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -189,7 +201,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py index 9ecd4d24a337..c9138ee43f6a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_database_sql_vulnerability_assessments_settings_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -78,7 +79,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -106,7 +107,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -178,7 +190,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 112b45bb5cde..0f97321fb38a 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -84,7 +85,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) error_map = { @@ -114,7 +115,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -187,7 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) request = build_get_request( 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 fde4eb753fe5..cb2e1c61edd7 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -72,7 +73,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -100,7 +101,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 3eba1658759e..97d82fce3bf3 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 @@ -101,7 +101,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -283,7 +283,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -382,7 +382,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 342f19229fd6..e4759887e98c 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,144 +60,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_initiate_scan_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, - api_version=api_version, - template_url=self._initiate_scan_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } - - @distributed_trace_async - async def begin_initiate_scan( - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Executes a Vulnerability Assessment database scan. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._initiate_scan_initial( # type: ignore - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } - @distributed_trace def list_by_database( self, @@ -228,7 +91,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -257,7 +120,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -331,7 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( @@ -411,7 +285,7 @@ async def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) request = build_export_request( @@ -454,3 +328,141 @@ async def export( export.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" } + + async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_initiate_scan_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, + api_version=api_version, + template_url=self._initiate_scan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _initiate_scan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + } + + @distributed_trace_async + async def begin_initiate_scan( + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Executes a Vulnerability Assessment database scan. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :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. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._initiate_scan_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_initiate_scan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + } 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 0f7bbb31f6a9..bccbfdd99cc0 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -58,6 +59,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabaseVulnerabilityAssessment"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database for which the vulnerability assessment policies + are defined. Required. + :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 DatabaseVulnerabilityAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments" + } + @distributed_trace_async async def get( self, @@ -96,7 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -252,7 +350,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -345,7 +443,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -379,89 +477,3 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DatabaseVulnerabilityAssessment"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database for which the vulnerability assessment policies - are defined. Required. - :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 DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments" - } 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 4e6d51f3ca66..d96efe5ecdb4 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -40,8 +41,6 @@ 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, build_rename_request, build_resume_request, @@ -72,176 +71,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_metrics( - self, resource_group_name: str, server_name: str, database_name: str, filter: str, **kwargs: Any - ) -> AsyncIterable["_models.Metric"]: - """Returns database metrics. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. - Required. - :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 Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metrics_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_metrics.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics" - } - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Returns database metric definitions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metric_definitions_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_metric_definitions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metric_definitions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions" - } - @distributed_trace def list_by_server( self, resource_group_name: str, server_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -263,7 +92,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -291,7 +120,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -365,7 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) request = build_get_request( @@ -424,7 +264,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) @@ -597,7 +437,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -660,7 +500,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -722,7 +562,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -784,7 +624,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) @@ -954,7 +794,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1021,7 +861,7 @@ async def _export_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -1191,7 +1031,7 @@ async def begin_export( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1256,7 +1096,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1327,7 +1167,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1388,7 +1228,7 @@ async def _import_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -1558,7 +1398,7 @@ async def begin_import_method( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1706,7 +1546,7 @@ async def rename( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1766,7 +1606,7 @@ async def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) request = build_pause_request( @@ -1835,7 +1675,7 @@ async def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1892,7 +1732,7 @@ async def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) request = build_resume_request( @@ -1961,7 +1801,7 @@ async def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2018,7 +1858,7 @@ async def _upgrade_data_warehouse_initial( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_upgrade_data_warehouse_request( @@ -2080,7 +1920,7 @@ async def begin_upgrade_data_warehouse( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2142,7 +1982,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2170,7 +2010,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -2223,7 +2074,7 @@ def list_inaccessible_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2250,7 +2101,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 03bfa370d9b9..977995ee72a0 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -71,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedServer"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) error_map = { @@ -96,7 +97,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -128,67 +140,6 @@ async def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers"} - @distributed_trace_async - async def get(self, 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. Required. - :type location_name: str - :param deleted_server_name: The name of the deleted server. Required. - :type deleted_server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedServer or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DeletedServer - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - - request = build_get_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("DeletedServer", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}" - } - @distributed_trace def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncIterable["_models.DeletedServer"]: """Gets a list of deleted servers for a location. @@ -203,7 +154,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncIterable[" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) error_map = { @@ -229,7 +180,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -263,6 +225,67 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers" } + @distributed_trace_async + async def get(self, 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. Required. + :type location_name: str + :param deleted_server_name: The name of the deleted server. Required. + :type deleted_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedServer or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.DeletedServer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) + + request = build_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DeletedServer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}" + } + async def _recover_initial( self, location_name: str, deleted_server_name: str, **kwargs: Any ) -> Optional[_models.DeletedServer]: @@ -277,7 +300,7 @@ async def _recover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.DeletedServer]] = kwargs.pop("cls", None) request = build_recover_request( @@ -342,7 +365,7 @@ async def begin_recover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py index 665f0f754a65..0496a44a5bcf 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_distributed_availability_groups_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,7 @@ build_delete_request, build_get_request, build_list_by_instance_request, + build_set_role_request, build_update_request, ) @@ -82,7 +84,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -109,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -176,7 +189,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -233,7 +246,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) @@ -406,7 +419,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -470,7 +483,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -536,7 +549,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -596,7 +609,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) @@ -766,7 +779,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -811,3 +824,240 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" } + + async def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO], + **kwargs: Any + ) -> Optional[_models.DistributedAvailabilityGroup]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupSetRole") + + request = build_set_role_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_role_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_role_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole" + } + + @overload + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupSetRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Is either a + DistributedAvailabilityGroupSetRole type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._set_role_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_set_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole" + } 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 deleted file mode 100644 index d290a62bb471..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -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]] - - -class ElasticPoolActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`elastic_pool_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ElasticPoolActivity"]: - """Returns elastic pool activities. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool for which to get the current activity. - Required. - :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 ElasticPoolActivity or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolActivityListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_elastic_pool.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_elastic_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity" - } 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 deleted file mode 100644 index f96cb4b20ca2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,137 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - 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.utils import case_insensitive_dict -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]] - - -class ElasticPoolDatabaseActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`elastic_pool_database_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ElasticPoolDatabaseActivity"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :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 ElasticPoolDatabaseActivity or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolDatabaseActivityListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_elastic_pool.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_elastic_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity" - } 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 48dff0581c25..4602080af95a 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -52,72 +53,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: Required. - :type elastic_pool_name: str - :param operation_id: The operation identifier. Required. - :type operation_id: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel" - } - @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any @@ -140,7 +75,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPoolOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -168,7 +103,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -201,3 +147,69 @@ async def get_next(next_link=None): list_by_elastic_pool.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations" } + + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param elastic_pool_name: Required. + :type elastic_pool_name: str + :param operation_id: The operation identifier. Required. + :type operation_id: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel" + } 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 c07625441acf..7faca2609aa1 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,8 +37,6 @@ build_failover_request, build_get_request, build_list_by_server_request, - build_list_metric_definitions_request, - build_list_metrics_request, build_update_request, ) @@ -64,176 +63,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_metrics( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, filter: str, **kwargs: Any - ) -> AsyncIterable["_models.Metric"]: - """Returns elastic pool metrics. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :type elastic_pool_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. - Required. - :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 Metric or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metrics_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_metrics.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics" - } - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinition"]: - """Returns elastic pool metric definitions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :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 MetricDefinition or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metric_definitions_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_metric_definitions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metric_definitions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions" - } - @distributed_trace def list_by_server( self, resource_group_name: str, server_name: str, skip: Optional[int] = None, **kwargs: Any @@ -255,7 +84,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPoolListResult] = kwargs.pop("cls", None) error_map = { @@ -283,7 +112,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -346,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) request = build_get_request( @@ -403,7 +243,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ElasticPool]] = kwargs.pop("cls", None) @@ -576,7 +416,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -639,7 +479,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -701,7 +541,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -763,7 +603,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ElasticPool]] = kwargs.pop("cls", None) @@ -933,7 +773,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -995,7 +835,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1057,7 +897,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 91c6399eef34..7cc7b44a7f5e 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) error_map = { @@ -106,7 +107,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -174,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) request = build_get_request( @@ -231,7 +243,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.EncryptionProtector]] = kwargs.pop("cls", None) @@ -404,7 +416,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -468,7 +480,7 @@ async def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revalidate_request( @@ -535,7 +547,7 @@ async def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py index b77ac4eb8a7b..9549e9a1d1c7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_endpoint_certificates_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -71,7 +72,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointCertificateListResult] = kwargs.pop("cls", None) error_map = { @@ -98,7 +99,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -162,7 +174,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) request = build_get_request( 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 7336f1f554a2..b8314e114508 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -113,7 +114,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -180,7 +192,7 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -331,7 +343,7 @@ async def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) 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 1d13749e1626..793d5d53d934 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -112,7 +113,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -177,7 +189,7 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -234,7 +246,7 @@ async def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] = kwargs.pop("cls", None) @@ -408,7 +420,7 @@ async def begin_create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 5a7d32428bb1..30703c21d4ab 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -83,7 +84,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -110,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -173,7 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -230,7 +242,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) @@ -403,7 +415,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -463,7 +475,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -525,7 +537,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -585,7 +597,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) @@ -755,7 +767,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -815,7 +827,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -884,7 +896,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -941,7 +953,7 @@ async def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -1011,7 +1023,7 @@ async def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1068,7 +1080,7 @@ async def _try_planned_before_forced_failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_try_planned_before_forced_failover_request( @@ -1142,7 +1154,7 @@ async def begin_try_planned_before_forced_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 d9ea93255425..e4ce49adc4ab 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,24 +60,28 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets a firewall rule. + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FirewallRule"]: + """Gets a list of 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: An iterator like instance of either FirewallRule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FirewallRule] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -85,136 +90,142 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - 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) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("FirewallRule", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + list_by_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" } @overload - async def create_or_update( + async def replace( self, resource_group_name: str, server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, + parameters: _models.FirewallRuleList, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def replace( self, resource_group_name: str, server_name: str, - firewall_rule_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Required. + :param parameters: Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], - **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + async def replace( + self, resource_group_name: str, server_name: str, parameters: Union[_models.FirewallRuleList, IO], **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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Is either - a FirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO + :param parameters: Is either a FirewallRuleList type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -228,9 +239,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -238,18 +249,17 @@ async def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "FirewallRule") + _json = self._serialize.body(parameters, "FirewallRuleList") - request = build_create_or_update_request( + request = build_replace_request( resource_group_name=resource_group_name, server_name=server_name, - firewall_rule_name=firewall_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self.replace.metadata["url"], headers=_headers, params=_params, ) @@ -263,30 +273,28 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: deserialized = self._deserialize("FirewallRule", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("FirewallRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) - return deserialized # type: ignore + return deserialized - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + replace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" } @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def get( self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a firewall rule. + ) -> _models.FirewallRule: + """Gets a 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. Required. @@ -296,8 +304,8 @@ async def delete( # pylint: disable=inconsistent-return-statements :param firewall_rule_name: The name of the firewall rule. Required. :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 + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -311,16 +319,16 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - request = build_delete_request( + 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, api_version=api_version, - template_url=self.delete.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -334,172 +342,110 @@ async def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" - } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.FirewallRule"]: - """Gets a list of 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 FirewallRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("FirewallRule", pipeline_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) - return AsyncItemPaged(get_next, extract_data) + return deserialized - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" } @overload - async def replace( + async def create_or_update( self, resource_group_name: str, server_name: str, - parameters: _models.FirewallRuleList, + firewall_rule_name: str, + parameters: _models.FirewallRule, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + ) -> _models.FirewallRule: + """Creates or updates a 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def replace( + async def create_or_update( self, resource_group_name: str, server_name: str, + firewall_rule_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + ) -> _models.FirewallRule: + """Creates or updates a 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Required. + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def replace( - self, resource_group_name: str, server_name: str, parameters: Union[_models.FirewallRuleList, IO], **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + async def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, IO], + **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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Is either a FirewallRuleList type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Is either + a FirewallRule type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -513,9 +459,9 @@ async def replace( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -523,17 +469,18 @@ async def replace( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "FirewallRuleList") + _json = self._serialize.body(parameters, "FirewallRule") - request = build_replace_request( + 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, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.replace.metadata["url"], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -547,19 +494,84 @@ async def replace( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - deserialized = None if response.status_code == 200: deserialized = self._deserialize("FirewallRule", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("FirewallRule", pipeline_response) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - replace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. Required. + :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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/firewallRules/{firewallRuleName}" } 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 a08cba5f9dd9..b0a530528105 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -31,7 +32,7 @@ from ...operations._geo_backup_policies_operations import ( build_create_or_update_request, build_get_request, - build_list_by_database_request, + build_list_request, ) T = TypeVar("T") @@ -57,6 +58,176 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GeoBackupPolicy"]: + """Gets a list of Geo backup policies for the given database resource. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies" + } + + @distributed_trace_async + async def get( + self, + 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 for the given database resource. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. + :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("GeoBackupPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" + } + @overload async def create_or_update( self, @@ -69,7 +240,7 @@ async def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -78,7 +249,8 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Required. @@ -104,7 +276,7 @@ async def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -113,7 +285,8 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Required. @@ -137,7 +310,7 @@ async def create_or_update( parameters: Union[_models.GeoBackupPolicy, IO], **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -146,7 +319,8 @@ async def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Is either a GeoBackupPolicy type or a IO type. Required. @@ -170,7 +344,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) @@ -224,161 +398,3 @@ async def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" } - - @distributed_trace_async - async def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. - :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - geo_backup_policy_name=geo_backup_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("GeoBackupPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" - } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GeoBackupPolicy"]: - """Returns a list of geo backup policies. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies" - } 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 1997b5885694..5d634900313f 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -82,7 +83,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -109,7 +110,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -172,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -229,7 +241,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) @@ -402,7 +414,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -462,7 +474,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -524,7 +536,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -579,7 +591,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -648,7 +660,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -705,7 +717,7 @@ async def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -775,7 +787,7 @@ async def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 413b56a94bee..0ac6b4c223e6 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -62,6 +63,172 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.InstancePool"]: + """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 InstancePool or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.InstancePool"]: + """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. Required. + :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 InstancePool or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools" + } + @distributed_trace_async async def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: """Gets an instance pool. @@ -87,7 +254,7 @@ async def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) request = build_get_request( @@ -142,7 +309,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstancePool]] = kwargs.pop("cls", None) @@ -305,7 +472,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -364,7 +531,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -423,7 +590,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -481,7 +648,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstancePool]] = kwargs.pop("cls", None) @@ -641,7 +808,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -685,147 +852,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.InstancePool"]: - """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. Required. - :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 InstancePool or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools" - } - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.InstancePool"]: - """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 InstancePool or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools"} 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 index ba45e5f4526b..eb6fd5c9e287 100644 --- 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -77,7 +78,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -104,7 +105,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -167,7 +179,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -309,7 +321,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) @@ -392,7 +404,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 4290e859dff1..1b8ffab78266 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobAgentListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -170,7 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) request = build_get_request( @@ -227,7 +239,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.JobAgent]] = kwargs.pop("cls", None) @@ -400,7 +412,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -460,7 +472,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -522,7 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -582,7 +594,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.JobAgent]] = kwargs.pop("cls", None) @@ -752,7 +764,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 200c2abb26d9..ffd571c49168 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobCredentialListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -172,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) request = build_get_request( @@ -322,7 +334,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) @@ -408,7 +420,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 71e8ba3c9810..79eb7dfc0f27 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -113,7 +114,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -148,7 +149,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -182,8 +194,143 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/executions" } + @distributed_trace + def list_by_job( + self, + 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 + ) -> AsyncIterable["_models.JobExecution"]: + """Lists a job's executions. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :type create_time_min: ~datetime.datetime + :param create_time_max: If specified, only job executions created before the specified time are + included. Default value is None. + :type create_time_max: ~datetime.datetime + :param end_time_min: If specified, only job executions completed at or after the specified time + are included. Default value is None. + :type end_time_min: ~datetime.datetime + :param end_time_max: If specified, only job executions completed before the specified time are + included. Default value is None. + :type end_time_max: ~datetime.datetime + :param is_active: If specified, only active or only completed job executions are included. + Default value is None. + :type is_active: bool + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :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 JobExecution or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions" + } + @distributed_trace_async - async def cancel( # pylint: disable=inconsistent-return-statements + async def get( self, resource_group_name: str, server_name: str, @@ -191,8 +338,8 @@ async def cancel( # pylint: disable=inconsistent-return-statements job_name: str, job_execution_id: str, **kwargs: Any - ) -> None: - """Requests cancellation of a job execution. + ) -> _models.JobExecution: + """Gets a job execution. :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. Required. @@ -203,11 +350,11 @@ async def cancel( # pylint: disable=inconsistent-return-statements :type job_agent_name: str :param job_name: The name of the job. Required. :type job_name: str - :param job_execution_id: The id of the job execution to cancel. Required. + :param job_execution_id: The id of the job execution. Required. :type job_execution_id: 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 + :return: JobExecution or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobExecution :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -221,10 +368,10 @@ async def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - request = build_cancel_request( + request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, job_agent_name=job_agent_name, @@ -232,7 +379,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -250,15 +397,25 @@ async def cancel( # pylint: disable=inconsistent-return-statements map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("JobExecution", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel" + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } - async def _create_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + async def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any ) -> Optional[_models.JobExecution]: error_map = { 401: ClientAuthenticationError, @@ -271,17 +428,18 @@ async def _create_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.JobExecution]] = kwargs.pop("cls", None) - request = build_create_request( + 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, + job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_initial.metadata["url"], + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -295,7 +453,7 @@ async def _create_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -303,20 +461,29 @@ async def _create_initial( if response.status_code == 200: deserialized = self._deserialize("JobExecution", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("JobExecution", pipeline_response) + if cls: 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" + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } @distributed_trace_async - async def begin_create( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + async def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any ) -> AsyncLROPoller[_models.JobExecution]: - """Starts an elastic job execution. + """Creates or updates a job execution. :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. Required. @@ -327,6 +494,8 @@ async def begin_create( :type job_agent_name: str :param job_name: The name of the job to get. Required. :type job_name: str + :param job_execution_id: The job execution id to create the job execution under. Required. + :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 @@ -343,17 +512,18 @@ async def begin_create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_or_update_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, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -383,136 +553,12 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" - } - - @distributed_trace - def list_by_job( - self, - 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 - ) -> AsyncIterable["_models.JobExecution"]: - """Lists a job's executions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param create_time_min: If specified, only job executions created at or after the specified - time are included. Default value is None. - :type create_time_min: ~datetime.datetime - :param create_time_max: If specified, only job executions created before the specified time are - included. Default value is None. - :type create_time_max: ~datetime.datetime - :param end_time_min: If specified, only job executions completed at or after the specified time - are included. Default value is None. - :type end_time_min: ~datetime.datetime - :param end_time_max: If specified, only job executions completed before the specified time are - included. Default value is None. - :type end_time_max: ~datetime.datetime - :param is_active: If specified, only active or only completed job executions are included. - Default value is None. - :type is_active: bool - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :param top: The number of elements to return from the collection. Default value is None. - :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 JobExecution or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_job.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions" + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } @distributed_trace_async - async def get( + async def cancel( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, @@ -520,8 +566,8 @@ async def get( job_name: str, job_execution_id: str, **kwargs: Any - ) -> _models.JobExecution: - """Gets a job execution. + ) -> None: + """Requests cancellation of a job execution. :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. Required. @@ -532,11 +578,11 @@ async def get( :type job_agent_name: str :param job_name: The name of the job. Required. :type job_name: str - :param job_execution_id: The id of the job execution. Required. + :param job_execution_id: The id of the job execution to cancel. Required. :type job_execution_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -550,10 +596,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_request( + request = build_cancel_request( resource_group_name=resource_group_name, server_name=server_name, job_agent_name=job_agent_name, @@ -561,7 +607,7 @@ async def get( job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], + template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) @@ -579,25 +625,15 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobExecution", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel" } - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any + async def _create_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any ) -> Optional[_models.JobExecution]: error_map = { 401: ClientAuthenticationError, @@ -610,18 +646,17 @@ async def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.JobExecution]] = kwargs.pop("cls", None) - request = build_create_or_update_request( + request = build_create_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, api_version=api_version, - template_url=self._create_or_update_initial.metadata["url"], + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -635,7 +670,7 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -643,29 +678,20 @@ async def _create_or_update_initial( if response.status_code == 200: deserialized = self._deserialize("JobExecution", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("JobExecution", pipeline_response) - if cls: 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}" + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" } @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any + async def begin_create( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.JobExecution]: - """Creates or updates a job execution. + """Starts an elastic job execution. :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. Required. @@ -676,8 +702,6 @@ async def begin_create_or_update( :type job_agent_name: str :param job_name: The name of the job to get. Required. :type job_name: str - :param job_execution_id: The job execution id to create the job execution under. Required. - :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 @@ -694,18 +718,17 @@ async def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_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, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -735,6 +758,6 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" } 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/_job_private_endpoints_operations.py similarity index 64% rename from sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py rename to sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_job_private_endpoints_operations.py index cb94d2cb128f..09a01ccf5334 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/_job_private_endpoints_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,25 +31,25 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._server_communication_links_operations import ( +from ...operations._job_private_endpoints_operations import ( build_create_or_update_request, build_delete_request, build_get_request, - build_list_by_server_request, + build_list_by_agent_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ServerCommunicationLinksOperations: +class JobPrivateEndpointsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`server_communication_links` attribute. + :attr:`job_private_endpoints` attribute. """ models = _models @@ -60,24 +61,30 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, communication_link_name: str, **kwargs: Any - ) -> None: - """Deletes a server communication link. + @distributed_trace + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobPrivateEndpoint"]: + """Gets a list of job agent private endpoints. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_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 + :return: An iterator like instance of either JobPrivateEndpoint or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobPrivateEndpointListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -86,59 +93,86 @@ async def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_by_agent.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("JobPrivateEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - 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) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + return AsyncItemPaged(get_next, extract_data) + + list_by_agent.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints" } @distributed_trace_async async def get( - self, resource_group_name: str, server_name: str, communication_link_name: str, **kwargs: Any - ) -> _models.ServerCommunicationLink: - """Returns a server communication link. + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> _models.JobPrivateEndpoint: + """Gets a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerCommunicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerCommunicationLink + :return: JobPrivateEndpoint or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -152,13 +186,14 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], @@ -179,7 +214,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -187,17 +222,18 @@ async def get( return deserialized get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } async def _create_or_update_initial( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, IO], **kwargs: Any - ) -> Optional[_models.ServerCommunicationLink]: + ) -> Optional[_models.JobPrivateEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -209,9 +245,9 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerCommunicationLink]] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.JobPrivateEndpoint]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -219,12 +255,13 @@ async def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ServerCommunicationLink") + _json = self._serialize.body(parameters, "JobPrivateEndpoint") request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -244,13 +281,16 @@ async def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [201, 202]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -258,7 +298,7 @@ async def _create_or_update_initial( return deserialized _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } @overload @@ -266,23 +306,26 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: _models.ServerCommunicationLink, + job_agent_name: str, + private_endpoint_name: str, + parameters: _models.JobPrivateEndpoint, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -294,9 +337,9 @@ async def begin_create_or_update( :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) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -305,22 +348,25 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, + job_agent_name: str, + private_endpoint_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Required. + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -333,9 +379,9 @@ async def begin_create_or_update( :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) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -344,22 +390,25 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> AsyncLROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Is either - a ServerCommunicationLink type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink or IO + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Is either a JobPrivateEndpoint type or + a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -371,17 +420,17 @@ async def begin_create_or_update( :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) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :return: An instance of AsyncLROPoller that returns either JobPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -389,7 +438,8 @@ async def begin_create_or_update( raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -401,13 +451,15 @@ async def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -422,32 +474,12 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerCommunicationLink"]: - """Gets a list of server communication links. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLinkListResult] = kwargs.pop("cls", None) - + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -456,52 +488,114 @@ def list_by_server( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_list_by_server_request( - resource_group_name=resource_group_name, - server_name=server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) - return pipeline_response + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" + } - return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to delete. Required. + :type private_endpoint_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. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } 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 22a6209d8d51..7d8dba7a1492 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -110,7 +111,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -147,7 +148,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -223,7 +235,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) request = build_get_request( 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 d0031e81a0d8..ba0d74306756 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,184 +61,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_version( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - **kwargs: Any - ) -> AsyncIterable["_models.JobStep"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param job_version: The version of the job to get. Required. - :type job_version: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_version.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_version.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps" - } - - @distributed_trace_async - async def get_by_version( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job. Required. - :type job_name: str - :param job_version: The version of the job to get. Required. - :type job_version: int - :param step_name: The name of the job step. Required. - :type step_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get_by_version.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("JobStep", pipeline_response) - - if cls: - 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}" - } - @distributed_trace def list_by_job( self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any @@ -261,7 +84,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) error_map = { @@ -290,7 +113,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -363,7 +197,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) request = build_get_request( @@ -523,7 +357,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) @@ -618,7 +452,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -653,3 +487,192 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}" } + + @distributed_trace + def list_by_version( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> AsyncIterable["_models.JobStep"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param job_version: The version of the job to get. Required. + :type job_version: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobStep or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_version.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_version.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps" + } + + @distributed_trace_async + async def get_by_version( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job. Required. + :type job_name: str + :param job_version: The version of the job to get. Required. + :type job_version: int + :param step_name: The name of the job step. Required. + :type step_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobStep or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get_by_version.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("JobStep", pipeline_response) + + if cls: + 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}" + } 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 c169dece87fc..c1c19efce0d0 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -58,13 +59,14 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_job_execution( + def list_by_step( self, 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, @@ -74,7 +76,7 @@ def list_by_job_execution( top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable["_models.JobExecution"]: - """Lists target executions for all steps of a job execution. + """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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -87,6 +89,8 @@ def list_by_job_execution( :type job_name: str :param job_execution_id: The id of the job execution. Required. :type job_execution_id: str + :param step_name: The name of the step. Required. + :type step_name: str :param create_time_min: If specified, only job executions created at or after the specified time are included. Default value is None. :type create_time_min: ~datetime.datetime @@ -114,7 +118,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -128,12 +132,13 @@ def list_by_job_execution( def prepare_request(next_link=None): if not next_link: - request = build_list_by_job_execution_request( + 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, @@ -143,7 +148,7 @@ def prepare_request(next_link=None): skip=skip, top=top, api_version=api_version, - template_url=self.list_by_job_execution.metadata["url"], + template_url=self.list_by_step.metadata["url"], headers=_headers, params=_params, ) @@ -151,7 +156,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -181,12 +197,12 @@ async def get_next(next_link=None): 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" + list_by_step.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets" } - @distributed_trace - def list_by_step( + @distributed_trace_async + async def get( self, resource_group_name: str, server_name: str, @@ -194,6 +210,92 @@ def list_by_step( 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param job_execution_id: The unique id of the job execution. Required. + :type job_execution_id: str + :param step_name: The name of the step. Required. + :type step_name: str + :param target_id: The target id. Required. + :type target_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobExecution or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("JobExecution", pipeline_response) + + if cls: + 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}" + } + + @distributed_trace + def list_by_job_execution( + self, + 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, @@ -203,7 +305,7 @@ def list_by_step( top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable["_models.JobExecution"]: - """Lists the target executions of a job step execution. + """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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -216,8 +318,6 @@ def list_by_step( :type job_name: str :param job_execution_id: The id of the job execution. Required. :type job_execution_id: str - :param step_name: The name of the step. Required. - :type step_name: str :param create_time_min: If specified, only job executions created at or after the specified time are included. Default value is None. :type create_time_min: ~datetime.datetime @@ -245,7 +345,7 @@ def list_by_step( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -259,13 +359,12 @@ def list_by_step( def prepare_request(next_link=None): if not next_link: - request = build_list_by_step_request( + 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, - step_name=step_name, subscription_id=self._config.subscription_id, create_time_min=create_time_min, create_time_max=create_time_max, @@ -275,7 +374,7 @@ def prepare_request(next_link=None): skip=skip, top=top, api_version=api_version, - template_url=self.list_by_step.metadata["url"], + template_url=self.list_by_job_execution.metadata["url"], headers=_headers, params=_params, ) @@ -283,7 +382,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -313,93 +423,6 @@ async def get_next(next_link=None): 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" - } - - @distributed_trace_async - async def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param job_execution_id: The unique id of the job execution. Required. - :type job_execution_id: str - :param step_name: The name of the step. Required. - :type step_name: str - :param target_id: The target id. Required. - :type target_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("JobExecution", pipeline_response) - - if cls: - 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}" + list_by_job_execution.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets" } 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 01039b7310f9..a58bc4afd61b 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobTargetGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -172,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -322,7 +334,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) @@ -408,7 +420,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 f8c2b538e26d..514c9cbf0896 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -75,7 +76,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobVersionListResult] = kwargs.pop("cls", None) error_map = { @@ -104,7 +105,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -177,7 +189,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobVersion] = kwargs.pop("cls", None) request = build_get_request( 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 56123e9f06ce..59d239b9792d 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -172,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) request = build_get_request( @@ -321,7 +333,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) @@ -407,7 +419,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 6f65e42ac581..7101d8b889fc 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,100 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LedgerDigestUploads"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads" + } + @distributed_trace_async async def get( self, @@ -96,7 +191,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +250,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) @@ -337,7 +432,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -384,89 +479,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" } - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LedgerDigestUploads"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads" - } - async def _disable_initial( self, resource_group_name: str, @@ -486,7 +498,7 @@ async def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) request = build_disable_request( @@ -564,7 +576,7 @@ async def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 8a226562f3eb..b32541f729a6 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -31,6 +32,8 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._long_term_retention_backups_operations import ( + build_change_access_tier_by_resource_group_request, + build_change_access_tier_request, build_copy_by_resource_group_request, build_copy_request, build_delete_by_resource_group_request, @@ -51,7 +54,7 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LongTermRetentionBackupsOperations: +class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,15 +73,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _copy_initial( + @distributed_trace + def list_by_location( self, location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> AsyncIterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location. + + :param location_name: The location of the database. Required. + :type location_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -87,117 +111,183 @@ async def _copy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + 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, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_copy_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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._copy_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - _copy_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" } - @overload - async def begin_copy( + @distributed_trace + def list_by_server( self, location_name: str, long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.CopyLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + ) -> AsyncIterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given server. :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def begin_copy( + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + } + + @distributed_trace + def list_by_database( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, - backup_name: str, - parameters: IO, - *, - content_type: str = "application/json", + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + ) -> AsyncIterable["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database. :param location_name: The location of the database. Required. :type location_name: str @@ -205,39 +295,234 @@ async def begin_copy( :type long_term_retention_server_name: str :param long_term_retention_database_name: The name of the database. Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + } @distributed_trace_async - async def begin_copy( + async def get( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LongTermRetentionBackup or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("LongTermRetentionBackup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_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, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + } + + @distributed_trace_async + async def begin_delete( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -247,12 +532,6 @@ async def begin_copy( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -261,30 +540,25 @@ async def begin_copy( :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] + :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._copy_initial( + raw_result = await self._delete_initial( # type: ignore 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, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -292,11 +566,9 @@ async def begin_copy( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -313,19 +585,19 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_copy.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - async def _update_initial( + async def _change_access_tier_initial( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> Optional[_models.LongTermRetentionBackup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -337,9 +609,9 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -347,9 +619,9 @@ async def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + _json = self._serialize.body(parameters, "ChangeLongTermRetentionBackupAccessTierParameters") - request = build_update_request( + request = build_change_access_tier_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, @@ -359,7 +631,7 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], + template_url=self._change_access_tier_initial.metadata["url"], headers=_headers, params=_params, ) @@ -375,45 +647,46 @@ async def _update_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: 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" + _change_access_tier_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } @overload - async def begin_update( + async def begin_change_access_tier( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: _models.UpdateLongTermRetentionBackupParameters, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -425,15 +698,14 @@ async def begin_update( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update( + async def begin_change_access_tier( self, location_name: str, long_term_retention_server_name: str, @@ -443,18 +715,18 @@ async def begin_update( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Required. + :param parameters: Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -467,36 +739,36 @@ async def begin_update( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update( + async def begin_change_access_tier( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a IO + type. Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -508,23 +780,22 @@ async def begin_update( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._change_access_tier_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, @@ -540,7 +811,7 @@ async def begin_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -560,34 +831,19 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + begin_change_access_tier.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } - @distributed_trace_async - async def get( + async def _copy_initial( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> _models.LongTermRetentionBackup: - """Gets a long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -596,20 +852,32 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - request = build_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + + request = build_copy_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, api_version=api_version, - template_url=self.get.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._copy_initial.metadata["url"], headers=_headers, params=_params, ) @@ -623,85 +891,118 @@ async def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + _copy_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - async def _delete_initial( # pylint: disable=inconsistent-return-statements + @overload + async def begin_copy( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: _models.CopyLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_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, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - if cls: - return cls(pipeline_response, None, {}) + @overload + async def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" - } + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_delete( + async def begin_copy( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -711,6 +1012,12 @@ async def begin_delete( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Is either a + CopyLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -719,25 +1026,30 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._copy_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, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -745,9 +1057,11 @@ async def begin_delete( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -764,21 +1078,178 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + begin_copy.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace - def list_by_database( + async def _update_initial( self, 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, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + + request = build_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + + if cls: + 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" + } + + @overload + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -786,6 +1257,94 @@ def list_by_database( :type long_term_retention_server_name: str :param long_term_retention_database_name: The name of the database. Required. :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is either a + UpdateLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + } + + @distributed_trace + def list_by_resource_group_location( + self, + resource_group_name: str, + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location based on 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. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -801,7 +1360,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -815,15 +1374,14 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + request = build_list_by_resource_group_location_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, api_version=api_version, - template_url=self.list_by_database.metadata["url"], + template_url=self.list_by_resource_group_location.metadata["url"], headers=_headers, params=_params, ) @@ -831,7 +1389,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -861,22 +1430,29 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + list_by_resource_group_location.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" } @distributed_trace - def list_by_location( + def list_by_resource_group_server( self, + 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 ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. + """Lists the long term retention backups for a given server based on resource groups. + :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. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -892,7 +1468,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -906,13 +1482,15 @@ def list_by_location( def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + 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, api_version=api_version, - template_url=self.list_by_location.metadata["url"], + template_url=self.list_by_resource_group_server.metadata["url"], headers=_headers, params=_params, ) @@ -920,7 +1498,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -950,25 +1539,32 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" + list_by_resource_group_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" } @distributed_trace - def list_by_server( + def list_by_resource_group_database( self, + 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 ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. + """Lists all long term retention backups for a database based on a particular 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. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -984,7 +1580,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -998,14 +1594,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + 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, api_version=api_version, - template_url=self.list_by_server.metadata["url"], + template_url=self.list_by_resource_group_database.metadata["url"], headers=_headers, params=_params, ) @@ -1013,7 +1611,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1043,20 +1652,38 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + list_by_resource_group_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" } - async def _copy_by_resource_group_initial( + @distributed_trace_async + async def get_by_resource_group( self, resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :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. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LongTermRetentionBackup or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1065,22 +1692,13 @@ async def _copy_by_resource_group_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - request = build_copy_by_resource_group_request( + 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, @@ -1088,10 +1706,7 @@ async def _copy_by_resource_group_initial( backup_name=backup_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._copy_by_resource_group_initial.metadata["url"], + template_url=self.get_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1105,127 +1720,88 @@ async def _copy_by_resource_group_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: 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" + get_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - @overload - async def begin_copy_by_resource_group( + async def _delete_by_resource_group_initial( # pylint: disable=inconsistent-return-statements self, 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, - *, - content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :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. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def begin_copy_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - :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. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + request = build_delete_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, + api_version=api_version, + template_url=self._delete_by_resource_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + } @distributed_trace_async - async def begin_copy_by_resource_group( + async def begin_delete_by_resource_group( self, resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + ) -> AsyncLROPoller[None]: + """Deletes a long term retention backup. :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. Required. @@ -1238,12 +1814,6 @@ async def begin_copy_by_resource_group( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -1252,31 +1822,26 @@ async def begin_copy_by_resource_group( :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] + :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._copy_by_resource_group_initial( + raw_result = await self._delete_by_resource_group_initial( # type: ignore 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, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1284,11 +1849,9 @@ async def begin_copy_by_resource_group( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1305,20 +1868,20 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_copy_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + begin_delete_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - async def _update_by_resource_group_initial( + async def _change_access_tier_by_resource_group_initial( self, resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> Optional[_models.LongTermRetentionBackup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1330,9 +1893,9 @@ async def _update_by_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1340,9 +1903,9 @@ async def _update_by_resource_group_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + _json = self._serialize.body(parameters, "ChangeLongTermRetentionBackupAccessTierParameters") - request = build_update_by_resource_group_request( + request = build_change_access_tier_by_resource_group_request( resource_group_name=resource_group_name, location_name=location_name, long_term_retention_server_name=long_term_retention_server_name, @@ -1353,7 +1916,7 @@ async def _update_by_resource_group_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_by_resource_group_initial.metadata["url"], + template_url=self._change_access_tier_by_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1369,49 +1932,50 @@ async def _update_by_resource_group_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: 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" + _change_access_tier_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } @overload - async def begin_update_by_resource_group( + async def begin_change_access_tier_by_resource_group( self, 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, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. :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. Required. :type resource_group_name: str - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1423,15 +1987,14 @@ async def begin_update_by_resource_group( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_update_by_resource_group( + async def begin_change_access_tier_by_resource_group( self, resource_group_name: str, location_name: str, @@ -1442,21 +2005,21 @@ async def begin_update_by_resource_group( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. :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. Required. :type resource_group_name: str - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Required. + :param parameters: Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1469,40 +2032,40 @@ async def begin_update_by_resource_group( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_update_by_resource_group( + async def begin_change_access_tier_by_resource_group( self, resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. :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. Required. :type resource_group_name: str - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a IO + type. Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1514,23 +2077,22 @@ async def begin_update_by_resource_group( :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] + :return: An instance of AsyncLROPoller that returns either LongTermRetentionBackup or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._update_by_resource_group_initial( + raw_result = await self._change_access_tier_by_resource_group_initial( resource_group_name=resource_group_name, location_name=location_name, long_term_retention_server_name=long_term_retention_server_name, @@ -1547,7 +2109,7 @@ async def begin_update_by_resource_group( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized @@ -1567,38 +2129,20 @@ def get_long_running_output(pipeline_response): ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + begin_change_access_tier_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } - @distributed_trace_async - async def get_by_resource_group( + async def _copy_by_resource_group_initial( self, resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1607,13 +2151,22 @@ async def get_by_resource_group( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - request = build_get_by_resource_group_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + + request = build_copy_by_resource_group_request( resource_group_name=resource_group_name, location_name=location_name, long_term_retention_server_name=long_term_retention_server_name, @@ -1621,7 +2174,10 @@ async def get_by_resource_group( backup_name=backup_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_resource_group.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._copy_by_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1635,88 +2191,37 @@ async def get_by_resource_group( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) if cls: 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}" - } - - async def _delete_by_resource_group_initial( # pylint: disable=inconsistent-return-statements - self, - 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: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_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, - api_version=api_version, - template_url=self._delete_by_resource_group_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_by_resource_group_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + _copy_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace_async - async def begin_delete_by_resource_group( + @overload + async def begin_copy_by_resource_group( self, 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, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a long term retention backup. + ) -> AsyncLROPoller[_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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1729,6 +2234,11 @@ async def begin_delete_by_resource_group( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1737,68 +2247,27 @@ async def begin_delete_by_resource_group( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_by_resource_group_initial( # type: ignore - 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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" - } - @distributed_trace - def list_by_resource_group_database( + @overload + async def begin_copy_by_resource_group( self, 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, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. + ) -> AsyncLROPoller[_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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1809,120 +2278,133 @@ def list_by_resource_group_database( :type long_term_retention_server_name: str :param long_term_retention_database_name: The name of the database. Required. :type long_term_retention_database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" - } - - @distributed_trace - def list_by_resource_group_location( + @distributed_trace_async + async def begin_copy_by_resource_group( self, resource_group_name: str, location_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. + ) -> AsyncLROPoller[_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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Is either a + CopyLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._copy_by_resource_group_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + begin_copy_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + } + + async def _update_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1931,69 +2413,77 @@ def list_by_resource_group_location( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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, - api_version=api_version, - template_url=self.list_by_resource_group_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - async def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + request = build_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_by_resource_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - async def get_next(next_link=None): - request = prepare_request(next_link) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) - list_by_resource_group_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" + 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" } - @distributed_trace - def list_by_resource_group_server( + @overload + async def begin_update_by_resource_group( self, 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, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. + ) -> AsyncLROPoller[_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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -2002,81 +2492,167 @@ def list_by_resource_group_server( :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + @overload + async def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :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. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @distributed_trace_async + async def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. - 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, - api_version=api_version, - template_url=self.list_by_resource_group_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + :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. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is either a + UpdateLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_by_resource_group_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, deserialized, {}) + return deserialized - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - 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) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_resource_group_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + begin_update_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } 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 39d74d7f1e77..622aa8635e70 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -65,6 +66,229 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_location( + self, + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists the long term retention backups for managed databases in a given location. + + :param location_name: The location of the database. Required. + :type location_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :type top: int + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 ManagedInstanceLongTermRetentionBackup or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + skip=skip, + top=top, + filter=filter, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/longTermRetentionManagedInstanceBackups" + } + + @distributed_trace + def list_by_database( + self, + 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 + ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists all long term retention backups for a managed database. + + :param location_name: The location of the database. Required. + :type location_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database. Required. + :type database_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 ManagedInstanceLongTermRetentionBackup or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + } + @distributed_trace_async async def get( self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any @@ -95,7 +319,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) request = build_get_request( @@ -148,7 +372,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -212,7 +436,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -255,23 +479,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- } @distributed_trace - def list_by_database( + def list_by_instance( self, 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 ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists all long term retention backups for a managed database. + """Lists the long term retention backups for a given managed instance. :param location_name: The location of the database. Required. :type location_name: str :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str - :param database_name: The name of the managed database. Required. - :type database_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -288,7 +509,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -302,15 +523,14 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + request = build_list_by_instance_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, api_version=api_version, - template_url=self.list_by_database.metadata["url"], + template_url=self.list_by_instance.metadata["url"], headers=_headers, params=_params, ) @@ -318,7 +538,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -348,31 +579,42 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" } @distributed_trace - def list_by_instance( + def list_by_resource_group_location( self, + 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, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for a given managed instance. + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool :param database_state: Whether to query against just live databases, just deleted databases, or all databases. Known values are: "All", "Live", and "Deleted". Default value is None. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :type top: int + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 ManagedInstanceLongTermRetentionBackup or the result of cls(response) @@ -383,7 +625,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -397,14 +639,17 @@ def list_by_instance( def prepare_request(next_link=None): if not next_link: - request = build_list_by_instance_request( + request = build_list_by_resource_group_location_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, + skip=skip, + top=top, + filter=filter, api_version=api_version, - template_url=self.list_by_instance.metadata["url"], + template_url=self.list_by_resource_group_location.metadata["url"], headers=_headers, params=_params, ) @@ -412,7 +657,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -442,22 +698,32 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" + list_by_resource_group_location.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" } @distributed_trace - def list_by_location( + def list_by_resource_group_database( self, + 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 ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for managed databases in a given location. + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database. Required. + :type database_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -474,7 +740,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -488,13 +754,16 @@ def list_by_location( def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + 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, api_version=api_version, - template_url=self.list_by_location.metadata["url"], + template_url=self.list_by_resource_group_database.metadata["url"], headers=_headers, params=_params, ) @@ -502,7 +771,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -532,8 +812,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" + list_by_resource_group_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" } @distributed_trace_async @@ -575,7 +855,7 @@ async def get_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) request = build_get_by_resource_group_request( @@ -635,7 +915,7 @@ async def _delete_by_resource_group_initial( # pylint: disable=inconsistent-ret _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_resource_group_request( @@ -709,7 +989,7 @@ async def begin_delete_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -752,109 +1032,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" } - @distributed_trace - def list_by_resource_group_database( - self, - 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 - ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database. Required. - :type database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" - } - @distributed_trace def list_by_resource_group_instance( self, @@ -890,7 +1067,7 @@ def list_by_resource_group_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -920,7 +1097,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -953,98 +1141,3 @@ async def get_next(next_link=None): list_by_resource_group_instance.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" } - - @distributed_trace - def list_by_resource_group_location( - self, - resource_group_name: str, - location_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" - } 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 149a64360d15..761aa0da2df9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,6 +60,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 LongTermRetentionPolicy or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies" + } + @distributed_trace_async async def get( self, @@ -95,7 +191,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -154,7 +250,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LongTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -334,7 +430,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -380,87 +476,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 LongTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies" - } 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 1eb83b9c3cbb..c60ef44f2b46 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 @@ -87,7 +87,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) request = build_get_request( 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 187b4e6ca77f..c1db75ecc424 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 @@ -87,7 +87,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) request = build_get_request( @@ -236,7 +236,7 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 d36198c9b212..de0bded50ec1 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedBackupShortTermRetentionPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :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 ManagedBackupShortTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies" + } + @distributed_trace_async async def get( self, @@ -96,7 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +252,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -338,7 +435,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -405,7 +502,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -588,7 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -634,88 +731,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedBackupShortTermRetentionPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :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 ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py index c29dad77ad40..7d1042f7ab17 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -180,7 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -336,7 +348,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) 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 21f3871edb69..3cad4b8225b5 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -97,7 +98,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -130,7 +131,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -199,7 +211,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -230,7 +242,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -306,7 +329,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py index ee79a0cc63ad..ab38bea52657 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_database_move_operations_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -84,7 +85,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseMoveOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -113,7 +114,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -176,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) request = build_get_request( 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 d9816ad3c3b8..1d6eb280688d 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -83,7 +84,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) request = build_get_request( @@ -160,7 +161,7 @@ def list_by_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceQueryStatistics] = kwargs.pop("cls", None) error_map = { @@ -192,7 +193,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 1c80504b76d6..82c6240418c4 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 @@ -153,7 +153,7 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 116741dcf95b..f48e6683d78d 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 @@ -86,7 +86,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) request = build_get_request( 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 91c289b3a1dd..aa8d1ec82303 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) error_map = { @@ -110,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) request = build_get_request( 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 338908aca31e..1c5baf79ffdf 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -57,6 +58,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedDatabaseSecurityAlertPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database for which the security alert policies + are defined. Required. + :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 ManagedDatabaseSecurityAlertPolicy or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies" + } + @distributed_trace_async async def get( self, @@ -76,7 +174,7 @@ async def get( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) @@ -94,7 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +253,7 @@ async def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy @@ -190,7 +288,7 @@ async def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: IO @@ -223,7 +321,7 @@ async def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Is either a ManagedDatabaseSecurityAlertPolicy type or a IO type. Required. @@ -247,7 +345,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) @@ -301,89 +399,3 @@ async def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedDatabaseSecurityAlertPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database for which the security alert policies - are defined. Required. - :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 ManagedDatabaseSecurityAlertPolicy or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies" - } 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 b13c4c82cc96..19d066358da0 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -91,7 +92,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityEventCollection] = kwargs.pop("cls", None) error_map = { @@ -123,7 +124,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 484f86a80b48..40e9bb86b2ea 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,7 @@ build_disable_recommendation_request, build_enable_recommendation_request, build_get_request, + build_list_by_database_request, build_list_current_by_database_request, build_list_recommended_by_database_request, build_update_request, @@ -67,6 +69,376 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_current_by_database( + self, + 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 + ) -> AsyncIterable["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param skip_token: Default value is None. + :type skip_token: str + :param count: Default value is None. + :type count: bool + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_current_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_current_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + } + + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.SensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace_async + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, IO], + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Is either a SensitivityLabelUpdateList type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + } + + @distributed_trace + def list_recommended_by_database( + self, + 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 + ) -> AsyncIterable["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param skip_token: Default value is None. + :type skip_token: str + :param include_disabled_recommendations: Specifies whether to include disabled recommendations + or not. Default value is None. + :type include_disabled_recommendations: bool + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_recommended_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_recommended_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + } + @distributed_trace_async async def get( self, @@ -113,7 +485,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) request = build_get_request( @@ -294,7 +666,7 @@ async def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) @@ -353,91 +725,7 @@ async def create_or_update( } @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } - - @distributed_trace_async - async def disable_recommendation( # pylint: disable=inconsistent-return-statements + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, @@ -447,7 +735,7 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme column_name: str, **kwargs: Any ) -> None: - """Disables sensitivity recommendations on a given column. + """Deletes the sensitivity label of a given column. :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. Required. @@ -462,8 +750,8 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. + :keyword sensitivity_label_source: The source of the sensitivity label. Default value is + "current". Note that overriding this default value may result in unsupported behavior. :paramtype sensitivity_label_source: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -481,11 +769,11 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_recommendation_request( + request = build_delete_request( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, database_name=database_name, @@ -495,7 +783,7 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - template_url=self.disable_recommendation.metadata["url"], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -516,12 +804,12 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" } @distributed_trace_async - async def enable_recommendation( # pylint: disable=inconsistent-return-statements + async def disable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, @@ -531,8 +819,7 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen column_name: str, **kwargs: Any ) -> None: - """Enables sensitivity recommendations on a given column (recommendations are enabled by default - on all columns). + """Disables sensitivity recommendations on a given column. :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. Required. @@ -567,10 +854,10 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_enable_recommendation_request( + request = build_disable_recommendation_request( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, database_name=database_name, @@ -580,7 +867,7 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - template_url=self.enable_recommendation.metadata["url"], + template_url=self.disable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -601,182 +888,23 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" - } - - @distributed_trace - def list_current_by_database( - self, - 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 - ) -> AsyncIterable["_models.SensitivityLabel"]: - """Gets the sensitivity labels of a given database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param skip_token: Default value is None. - :type skip_token: str - :param count: Default value is None. - :type count: bool - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :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 SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_current_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_current_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + disable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" } - @overload - async def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.SensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: 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: - """ - - @overload - async def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: 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: - """ - @distributed_trace_async - async def update( # pylint: disable=inconsistent-return-statements + async def enable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, database_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO], + schema_name: str, + table_name: str, + column_name: str, **kwargs: Any ) -> None: - """Update sensitivity labels of a given database using an operations batch. + """Enables sensitivity recommendations on a given column (recommendations are enabled by default + on all columns). :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. Required. @@ -785,11 +913,15 @@ async def update( # pylint: disable=inconsistent-return-statements :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str - :param parameters: Is either a SensitivityLabelUpdateList type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. + :paramtype sensitivity_label_source: 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 @@ -803,31 +935,24 @@ async def update( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") - - request = build_update_request( + 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, + sensitivity_label_source=sensitivity_label_source, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], + template_url=self.enable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -848,18 +973,16 @@ async def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + enable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" } @distributed_trace - def list_recommended_by_database( + def list_by_database( self, 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 ) -> AsyncIterable["_models.SensitivityLabel"]: @@ -872,11 +995,6 @@ def list_recommended_by_database( :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str - :param skip_token: Default value is None. - :type skip_token: str - :param include_disabled_recommendations: Specifies whether to include disabled recommendations - or not. Default value is None. - :type include_disabled_recommendations: bool :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str @@ -888,7 +1006,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -902,16 +1020,14 @@ def list_recommended_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_recommended_by_database_request( + 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, - skip_token=skip_token, - include_disabled_recommendations=include_disabled_recommendations, filter=filter, api_version=api_version, - template_url=self.list_recommended_by_database.metadata["url"], + template_url=self.list_by_database.metadata["url"], headers=_headers, params=_params, ) @@ -919,7 +1035,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -949,6 +1076,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_recommended_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/sensitivityLabels" } 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 991583ca043f..0d4e12708ce4 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -84,7 +85,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) error_map = { @@ -114,7 +115,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -187,7 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) request = build_get_request( 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 e535f3b6b8b1..5faabc40665d 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -57,6 +58,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedTransparentDataEncryption"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database for which the transparent data + encryption is defined. Required. + :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 ManagedTransparentDataEncryption or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption" + } + @distributed_trace_async async def get( self, @@ -94,7 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) request = build_get_request( @@ -247,7 +345,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) @@ -301,89 +399,3 @@ async def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedTransparentDataEncryption"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database for which the transparent data - encryption is defined. Required. - :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 ManagedTransparentDataEncryption or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption" - } 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 53c3b94aed6c..5ed8a869099b 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 @@ -101,7 +101,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -283,7 +283,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -382,7 +382,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 d93cbebab65b..f67cd7e614c7 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,15 +60,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + @distributed_trace + def list_by_database( self, resource_group_name: str, managed_instance_name: str, database_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, **kwargs: Any - ) -> None: + ) -> AsyncIterable["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :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 VulnerabilityAssessmentScanRecord or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -76,47 +102,71 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_initiate_scan_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, - api_version=api_version, - template_url=self._initiate_scan_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + 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" } @distributed_trace_async - async def begin_initiate_scan( + async def get( self, resource_group_name: str, managed_instance_name: str, @@ -124,8 +174,8 @@ async def begin_initiate_scan( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Executes a Vulnerability Assessment database scan. + ) -> _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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -140,61 +190,59 @@ async def begin_initiate_scan( :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: VulnerabilityAssessmentScanRecord or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._initiate_scan_initial( # type: ignore - 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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + 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("VulnerabilityAssessmentScanRecord", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" } @distributed_trace_async @@ -237,7 +285,7 @@ async def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) request = build_export_request( @@ -281,40 +329,15 @@ async def export( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" } - @distributed_trace - def list_by_database( + async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, database_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, **kwargs: Any - ) -> AsyncIterable["_models.VulnerabilityAssessmentScanRecord"]: - """Lists the vulnerability assessment scans of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :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 VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -323,60 +346,47 @@ def list_by_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - async def extract_data(pipeline_response): - deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - async def get_next(next_link=None): - request = prepare_request(next_link) + request = build_initiate_scan_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, + api_version=api_version, + template_url=self._initiate_scan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - 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) + response = pipeline_response.http_response - return pipeline_response + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, None, {}) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + _initiate_scan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" } @distributed_trace_async - async def get( + async def begin_initiate_scan( self, resource_group_name: str, managed_instance_name: str, @@ -384,8 +394,8 @@ async def get( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. + ) -> AsyncLROPoller[None]: + """Executes a Vulnerability Assessment database scan. :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. Required. @@ -400,57 +410,59 @@ async def get( :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("VulnerabilityAssessmentScanRecord", pipeline_response) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._initiate_scan_initial( # type: ignore + 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, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - return deserialized + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + begin_initiate_scan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" } 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 90db21a6056e..955395872076 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -58,6 +59,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessments of a managed database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database for which the vulnerability assessment is + defined. Required. + :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 DatabaseVulnerabilityAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments" + } + @distributed_trace_async async def get( self, @@ -96,7 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -252,7 +350,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -345,7 +443,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -379,89 +477,3 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DatabaseVulnerabilityAssessment"]: - """Lists the vulnerability assessments of a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database for which the vulnerability assessment is - defined. Required. - :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 DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments" - } 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 de7818d9588b..73ff10625c44 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -112,7 +113,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( @@ -232,7 +244,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedDatabase]] = kwargs.pop("cls", None) @@ -405,7 +417,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -465,7 +477,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -527,7 +539,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -587,7 +599,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedDatabase]] = kwargs.pop("cls", None) @@ -757,7 +769,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -822,7 +834,7 @@ async def _cancel_move_initial( # pylint: disable=inconsistent-return-statement _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -983,7 +995,7 @@ async def begin_cancel_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1046,7 +1058,7 @@ async def _complete_move_initial( # pylint: disable=inconsistent-return-stateme _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1207,7 +1219,7 @@ async def begin_complete_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1270,7 +1282,7 @@ async def _complete_restore_initial( # pylint: disable=inconsistent-return-stat _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1433,7 +1445,7 @@ async def begin_complete_restore( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1496,7 +1508,7 @@ async def _start_move_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1657,7 +1669,7 @@ async def begin_start_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1720,7 +1732,7 @@ def list_inaccessible_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -1747,7 +1759,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 553633be8c81..d4fb4cc2ca71 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdministratorListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) request = build_get_request( @@ -232,7 +244,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAdministrator]] = kwargs.pop("cls", None) @@ -405,7 +417,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -469,7 +481,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -535,7 +547,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py index fb599ad37d3f..632744a6f299 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -176,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -233,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAdvancedThreatProtection]] = kwargs.pop("cls", None) @@ -412,7 +424,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 2e98d3f7c432..42ec842cd5fc 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,99 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedInstanceAzureADOnlyAuthentication"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedInstanceAzureADOnlyAuthentication or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications" + } + @distributed_trace_async async def get( self, @@ -94,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) request = build_get_request( @@ -151,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAzureADOnlyAuthentication]] = kwargs.pop("cls", None) @@ -336,7 +430,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -400,7 +494,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -467,7 +561,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -507,85 +601,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedInstanceAzureADOnlyAuthentication"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedInstanceAzureADOnlyAuthentication or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py index 481677f2a479..b6257a82ffb1 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_instance_dtcs_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -78,7 +79,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceDtcListResult] = kwargs.pop("cls", None) error_map = { @@ -105,7 +106,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -168,7 +180,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) request = build_get_request( @@ -225,7 +237,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) @@ -393,7 +405,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 339ffbc022b7..1ec51b1248fb 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,132 +61,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _revalidate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_revalidate_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, - api_version=api_version, - template_url=self._revalidate_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _revalidate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } - - @distributed_trace_async - async def begin_revalidate( - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Revalidates an existing encryption protector. - - :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. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param encryption_protector_name: The name of the encryption protector to be updated. "current" - Required. - :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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._revalidate_initial( # type: ignore - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_revalidate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } - @distributed_trace def list_by_instance( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any @@ -207,7 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceEncryptionProtectorListResult] = kwargs.pop("cls", None) error_map = { @@ -234,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -302,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) request = build_get_request( @@ -359,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceEncryptionProtector]] = kwargs.pop("cls", None) @@ -535,7 +421,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -580,3 +466,129 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}" } + + async def _revalidate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revalidate_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, + api_version=api_version, + template_url=self._revalidate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _revalidate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" + } + + @distributed_trace_async + async def begin_revalidate( + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Revalidates an existing encryption protector. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param encryption_protector_name: The name of the encryption protector to be updated. "current" + Required. + :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. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._revalidate_initial( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_revalidate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" + } 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 b562ae8bd2f4..e95e08e790c2 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -82,7 +83,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceKeyListResult] = kwargs.pop("cls", None) error_map = { @@ -110,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -173,7 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) request = build_get_request( @@ -230,7 +242,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceKey]] = kwargs.pop("cls", None) @@ -406,7 +418,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -466,7 +478,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -528,7 +540,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 5186af09b8b9..a4d1597ed5b8 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -32,6 +33,7 @@ from ..._vendor import _convert_request from ...operations._managed_instance_long_term_retention_policies_operations import ( build_create_or_update_request, + build_delete_request, build_get_request, build_list_by_database_request, ) @@ -59,6 +61,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :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 ManagedInstanceLongTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies" + } + @distributed_trace_async async def get( self, @@ -95,7 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -154,7 +252,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -337,7 +435,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -384,11 +482,76 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedInstanceLongTermRetentionPolicy"]: - """Gets a database's long term retention policy. + async def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> Optional[_models.ManagedInstanceLongTermRetentionPolicy]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) + + request = build_delete_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, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + } + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Deletes a managed database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -397,74 +560,65 @@ def list_by_database( :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str + :param policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicy or the - result of cls(response) + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ManagedInstanceLongTermRetentionPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicyListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response) if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, deserialized, {}) + return deserialized - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - 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) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } 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 8a7550e5831c..1d83a5d2df6c 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -77,7 +78,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -104,7 +105,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -167,7 +179,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) request = build_get_request( @@ -234,7 +246,7 @@ async def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( 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 162e14e6f7b8..55e1ccede4a2 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,99 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedInstancePrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedInstancePrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_managed_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_managed_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections" + } + @distributed_trace_async async def get( self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -89,7 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -146,7 +240,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstancePrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -319,7 +413,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -379,7 +473,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -441,7 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -481,85 +575,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}" } - - @distributed_trace - def list_by_managed_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedInstancePrivateEndpointConnection"]: - """Gets all private endpoint connections on a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedInstancePrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_managed_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_managed_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_managed_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections" - } 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 9f3bad521a79..0ad174db9be5 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -76,7 +77,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -103,7 +104,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -166,7 +178,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) request = build_get_request( 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 89edb61358c2..b233cef8be9a 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 @@ -71,7 +71,7 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -222,7 +222,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 65367d3bb509..16a828c14ad6 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -58,6 +59,100 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedInstanceVulnerabilityAssessment"]: + """Gets the managed instance's vulnerability assessment policies. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance for which the vulnerability + assessments is defined. Required. + :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 ManagedInstanceVulnerabilityAssessment or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments" + } + @distributed_trace_async async def get( self, @@ -93,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -245,7 +340,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -334,7 +429,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -367,86 +462,3 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedInstanceVulnerabilityAssessment"]: - """Gets the managed instance's vulnerability assessment policies. - - :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. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance for which the vulnerability - assessments is defined. Required. - :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 ManagedInstanceVulnerabilityAssessment or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments" - } 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 402a997f9789..73e6e820da25 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -40,6 +41,7 @@ build_list_by_resource_group_request, build_list_outbound_network_dependencies_by_managed_instance_request, build_list_request, + build_refresh_status_request, build_start_request, build_stop_request, build_update_request, @@ -82,7 +84,7 @@ def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +110,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -161,7 +174,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -189,7 +202,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -242,7 +266,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -269,7 +293,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -332,7 +367,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) request = build_get_request( @@ -388,7 +423,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) @@ -551,7 +586,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -610,7 +645,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -669,7 +704,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -727,7 +762,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) @@ -887,7 +922,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -950,7 +985,7 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1017,7 +1052,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1079,7 +1114,7 @@ def list_outbound_network_dependencies_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) error_map = { @@ -1106,7 +1141,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1140,9 +1186,9 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints" } - async def _start_initial( # pylint: disable=inconsistent-return-statements + async def _refresh_status_initial( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> None: + ) -> Optional[_models.RefreshExternalGovernanceStatusOperationResultMI]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1154,8 +1200,134 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.RefreshExternalGovernanceStatusOperationResultMI]] = kwargs.pop("cls", None) + + request = build_refresh_status_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_status_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _refresh_status_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus" + } + + @distributed_trace_async + async def begin_refresh_status( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]: + """Refresh external governance enablement status. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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. + :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 + RefreshExternalGovernanceStatusOperationResultMI or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RefreshExternalGovernanceStatusOperationResultMI] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_status_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh_status.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus" + } + + async def _start_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Optional[_models.ManagedInstance]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) request = build_start_request( resource_group_name=resource_group_name, @@ -1176,12 +1348,18 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstance", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _start_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start" @@ -1190,7 +1368,7 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def begin_start( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.ManagedInstance]: """Starts the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1206,20 +1384,21 @@ async def begin_start( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either ManagedInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._start_initial( # type: ignore + raw_result = await self._start_initial( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, api_version=api_version, @@ -1230,9 +1409,11 @@ async def begin_start( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstance", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1255,9 +1436,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start" } - async def _stop_initial( # pylint: disable=inconsistent-return-statements + async def _stop_initial( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> None: + ) -> Optional[_models.ManagedInstance]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1269,8 +1450,8 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) request = build_stop_request( resource_group_name=resource_group_name, @@ -1291,12 +1472,18 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstance", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _stop_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop" @@ -1305,7 +1492,7 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def begin_stop( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: + ) -> AsyncLROPoller[_models.ManagedInstance]: """Stops the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1321,20 +1508,21 @@ async def begin_stop( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An instance of AsyncLROPoller that returns either ManagedInstance or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ManagedInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._stop_initial( # type: ignore + raw_result = await self._stop_initial( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, api_version=api_version, @@ -1345,9 +1533,11 @@ async def begin_stop( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstance", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1418,7 +1608,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TopQueriesListResult] = kwargs.pop("cls", None) error_map = { @@ -1452,7 +1642,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py index 0a27fa691817..f3ce20ce403f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_ledger_digest_uploads_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -83,7 +84,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploadsListResult] = kwargs.pop("cls", None) error_map = { @@ -111,7 +112,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -181,7 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) request = build_get_request( @@ -240,7 +252,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) @@ -426,7 +438,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -492,7 +504,7 @@ async def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) request = build_disable_request( @@ -570,7 +582,7 @@ async def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 50e0ad42eca5..ca7949e67cee 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,102 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_restorable_dropped_database( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedBackupShortTermRetentionPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param restorable_dropped_database_id: Required. + :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 ManagedBackupShortTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_restorable_dropped_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_restorable_dropped_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies" + } + @distributed_trace_async async def get( self, @@ -96,7 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -155,7 +252,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -338,7 +435,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -405,7 +502,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -588,7 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -634,88 +731,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_restorable_dropped_database( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedBackupShortTermRetentionPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param restorable_dropped_database_id: Required. - :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 ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_restorable_dropped_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_restorable_dropped_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py index 67f8fab6705d..13abb3e83e6e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_managed_server_dns_aliases_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerDnsAliasListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -171,7 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) request = build_get_request( @@ -228,7 +240,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) @@ -400,7 +412,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -460,7 +472,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -522,7 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -582,7 +594,7 @@ async def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) @@ -751,7 +763,7 @@ async def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 dfbe1d111b98..d9230141d10d 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,12 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedServerSecurityAlertPolicy"]: + """Get the managed server's threat detection policies. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedServerSecurityAlertPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" + } + @distributed_trace_async async def get( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], **kwargs: Any ) -> _models.ManagedServerSecurityAlertPolicy: """Get a managed server's threat detection policy. @@ -75,7 +169,8 @@ async def get( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy @@ -92,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -134,7 +229,7 @@ async def _create_or_update_initial( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO], **kwargs: Any ) -> Optional[_models.ManagedServerSecurityAlertPolicy]: @@ -149,7 +244,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerSecurityAlertPolicy]] = kwargs.pop("cls", None) @@ -206,7 +301,7 @@ async def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: _models.ManagedServerSecurityAlertPolicy, *, content_type: str = "application/json", @@ -220,7 +315,8 @@ async def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -246,7 +342,7 @@ async def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: IO, *, content_type: str = "application/json", @@ -260,7 +356,8 @@ async def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -286,7 +383,7 @@ async def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO], **kwargs: Any ) -> AsyncLROPoller[_models.ManagedServerSecurityAlertPolicy]: @@ -298,7 +395,8 @@ async def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Is either a ManagedServerSecurityAlertPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or IO @@ -322,7 +420,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -367,85 +465,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagedServerSecurityAlertPolicy"]: - """Get the managed server's threat detection policies. - - :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. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedServerSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_network_security_perimeter_configurations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..af8744e22264 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_network_security_perimeter_configurations_operations.py @@ -0,0 +1,349 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._network_security_perimeter_configurations_operations import ( + build_get_request, + build_list_by_server_request, + build_reconcile_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NetworkSecurityPerimeterConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s + :attr:`network_security_perimeter_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("NetworkSecurityPerimeterConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/networkSecurityPerimeterConfigurations" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets a network security perimeter configuration. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}" + } + + async def _reconcile_initial( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> Optional[_models.NetworkSecurityPerimeterConfiguration]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + request = build_reconcile_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reconcile_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reconcile_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } + + @distributed_trace_async + async def begin_reconcile( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.NetworkSecurityPerimeterConfiguration]: + """Reconcile network security perimeter configuration for SQL Resource Provider. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_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. + :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 + NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reconcile_initial( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_reconcile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } 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 7c1b35374fc8..ba4e76cdb1e9 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -63,7 +64,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -87,7 +88,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 cf658911e77c..cb7aac23c5df 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 @@ -6,8 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +60,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OutboundFirewallRule"]: + """Gets all outbound firewall rules on a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 OutboundFirewallRule or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/outboundFirewallRules" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any @@ -89,7 +181,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -128,12 +220,7 @@ async def get( } async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO], - **kwargs: Any + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any ) -> Optional[_models.OutboundFirewallRule]: error_map = { 401: ClientAuthenticationError, @@ -143,30 +230,18 @@ async def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.OutboundFirewallRule]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "OutboundFirewallRule") - request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, @@ -201,92 +276,9 @@ async def _create_or_update_initial( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" } - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: _models.OutboundFirewallRule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param outbound_rule_fqdn: Required. - :type outbound_rule_fqdn: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OutboundFirewallRule or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param outbound_rule_fqdn: Required. - :type outbound_rule_fqdn: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OutboundFirewallRule or the result - of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO], - **kwargs: Any + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any ) -> AsyncLROPoller[_models.OutboundFirewallRule]: """Create a outbound firewall rule with a given name. @@ -297,11 +289,6 @@ async def begin_create_or_update( :type server_name: str :param outbound_rule_fqdn: Required. :type outbound_rule_fqdn: str - :param parameters: Is either a OutboundFirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -315,11 +302,10 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -329,9 +315,7 @@ async def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -378,7 +362,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -440,7 +424,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -480,84 +464,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OutboundFirewallRule"]: - """Gets all outbound firewall rules on a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/outboundFirewallRules" - } 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 21e23a3ebef2..bcc6b5fa3f7e 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -171,7 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -228,7 +240,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -397,7 +409,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -457,7 +469,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -519,7 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 febda131aa8c..952818c2b68f 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -71,7 +72,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -98,7 +99,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -161,7 +173,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( 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 8d320a0b4c5b..abff0d47afdb 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 @@ -153,7 +153,7 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 351fa8d7305a..3096ecfd354d 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -71,7 +72,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -98,7 +99,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -172,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 d3e4369bbbdd..9d27ad497305 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -73,7 +74,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -100,7 +101,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -163,7 +175,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 374d381348ef..51b489b38b02 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -82,7 +83,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -110,7 +111,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) request = build_get_request( @@ -228,7 +240,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -293,7 +305,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -349,7 +361,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ReplicationLink]] = kwargs.pop("cls", None) request = build_failover_request( @@ -421,7 +433,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -479,7 +491,7 @@ async def _failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ReplicationLink]] = kwargs.pop("cls", None) request = build_failover_allow_data_loss_request( @@ -551,7 +563,7 @@ async def begin_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -614,7 +626,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -641,7 +653,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 9f29fcfcba70..9aaa4933446d 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -73,7 +74,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -100,7 +101,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -174,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 0a1e53d99e27..00428425196b 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -76,7 +77,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -103,7 +104,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -166,7 +178,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 8f46dfab008c..a648eb7a93b8 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) error_map = { @@ -109,7 +110,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -162,7 +174,7 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.RestorePoint]] = kwargs.pop("cls", None) @@ -335,7 +347,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -412,7 +424,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) request = build_get_request( @@ -482,7 +494,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 0c0817136434..00ba062ef2c5 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,7 @@ build_disable_recommendation_request, build_enable_recommendation_request, build_get_request, + build_list_by_database_request, build_list_current_by_database_request, build_list_recommended_by_database_request, build_update_request, @@ -102,7 +104,7 @@ def list_current_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -133,7 +135,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -268,7 +281,7 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -350,7 +363,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -381,7 +394,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -415,175 +439,6 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/recommendedSensitivityLabels" } - @distributed_trace_async - async def enable_recommendation( # pylint: disable=inconsistent-return-statements - self, - 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). - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - template_url=self.enable_recommendation.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" - } - - @distributed_trace_async - async def disable_recommendation( # pylint: disable=inconsistent-return-statements - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - template_url=self.disable_recommendation.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" - } - @distributed_trace_async async def get( self, @@ -630,7 +485,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) request = build_get_request( @@ -811,7 +666,7 @@ async def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) @@ -915,7 +770,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -952,3 +807,275 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" } + + @distributed_trace_async + async def disable_recommendation( # pylint: disable=inconsistent-return-statements + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. + :paramtype sensitivity_label_source: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + sensitivity_label_source=sensitivity_label_source, + api_version=api_version, + template_url=self.disable_recommendation.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + disable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" + } + + @distributed_trace_async + async def enable_recommendation( # pylint: disable=inconsistent-return-statements + self, + 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). + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. + :paramtype sensitivity_label_source: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + sensitivity_label_source=sensitivity_label_source, + api_version=api_version, + template_url=self.enable_recommendation.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + enable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" + } + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sensitivityLabels" + } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py index 88703fe63835..3f8aebfacd8d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalServerAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -176,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -233,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAdvancedThreatProtection]] = kwargs.pop("cls", None) @@ -412,7 +424,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 a9aebcc2b12f..a084b7fdb111 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 @@ -84,7 +84,7 @@ async def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) request = build_list_by_server_request( @@ -151,7 +151,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) request = build_get_request( @@ -291,7 +291,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) 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 e4fb53f6414d..d2a1c6f0c1cc 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 @@ -76,7 +76,7 @@ async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) request = build_get_request( @@ -206,7 +206,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) 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 558dadd457f0..9d2bf7d76cf7 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,99 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerAzureADAdministrator"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerAzureADAdministrator or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/administrators" + } + @distributed_trace_async async def get( self, @@ -94,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) request = build_get_request( @@ -151,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAzureADAdministrator]] = kwargs.pop("cls", None) @@ -327,7 +421,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -391,7 +485,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -458,7 +552,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -498,85 +592,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerAzureADAdministrator"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerAzureADAdministrator or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/administrators" - } 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 75171e371018..eeaac1ae8081 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,99 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerAzureADOnlyAuthentication"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerAzureADOnlyAuthentication or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/azureADOnlyAuthentications" + } + @distributed_trace_async async def get( self, @@ -94,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) request = build_get_request( @@ -151,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAzureADOnlyAuthentication]] = kwargs.pop("cls", None) @@ -336,7 +430,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -400,7 +494,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -467,7 +561,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -507,85 +601,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerAzureADOnlyAuthentication"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerAzureADOnlyAuthentication or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/azureADOnlyAuthentications" - } 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 ccdef22e00c7..6202601704d9 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -112,7 +113,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -175,7 +187,7 @@ async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -232,7 +244,7 @@ async def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerBlobAuditingPolicy]] = kwargs.pop("cls", None) @@ -403,7 +415,7 @@ async def begin_create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_configuration_options_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_configuration_options_operations.py index 516ba4a9dfb0..e989caad2c20 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_configuration_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_configuration_options_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConfigurationOptionListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -176,7 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) request = build_get_request( @@ -233,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) @@ -407,7 +419,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 d96971f6824e..3399b38b934c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,6 +60,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerConnectionPolicy"]: + """Lists connection policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerConnectionPolicy or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" + } + @distributed_trace_async async def get( self, @@ -92,7 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -149,7 +242,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerConnectionPolicy]] = kwargs.pop("cls", None) @@ -319,7 +412,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -364,84 +457,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerConnectionPolicy"]: - """Lists connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" - } 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 a4fa199bc448..25a53f056a63 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -80,7 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDevOpsAuditSettingsListResult] = kwargs.pop("cls", None) error_map = { @@ -107,7 +108,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -174,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) request = build_get_request( @@ -231,7 +243,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerDevOpsAuditingSettings]] = kwargs.pop("cls", None) @@ -401,7 +413,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 522200acf365..05d9cc07cf3b 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -61,6 +62,97 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerDnsAlias"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server that the alias is pointing to. Required. + :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 ServerDnsAlias or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/dnsAliases" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any @@ -90,7 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) request = build_get_request( @@ -142,7 +234,7 @@ async def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ServerDnsAlias]] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -214,7 +306,7 @@ async def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -271,7 +363,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -333,7 +425,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -374,86 +466,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerDnsAlias"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server that the alias is pointing to. Required. - :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 ServerDnsAlias or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/dnsAliases" - } - async def _acquire_initial( self, resource_group_name: str, @@ -473,7 +485,7 @@ async def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerDnsAlias]] = kwargs.pop("cls", None) @@ -642,7 +654,7 @@ async def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 4290d88fed3f..76c298509883 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerKeyListResult] = kwargs.pop("cls", None) error_map = { @@ -106,7 +107,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -167,7 +179,7 @@ async def get(self, resource_group_name: str, server_name: str, key_name: str, * _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) request = build_get_request( @@ -224,7 +236,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerKey]] = kwargs.pop("cls", None) @@ -406,7 +418,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -466,7 +478,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -528,7 +540,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 3de23397293d..541193f7b371 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -70,7 +71,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -97,7 +98,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 e13330e36c24..e6b89589c6f9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -59,12 +60,105 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerSecurityAlertPolicy"]: + """Get the server's threat detection policies. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerSecurityAlertPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/securityAlertPolicies" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], **kwargs: Any ) -> _models.ServerSecurityAlertPolicy: """Get a server's security alert policy. @@ -75,7 +169,8 @@ async def get( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy @@ -92,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -134,7 +229,7 @@ async def _create_or_update_initial( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any ) -> Optional[_models.ServerSecurityAlertPolicy]: @@ -149,7 +244,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerSecurityAlertPolicy]] = kwargs.pop("cls", None) @@ -206,7 +301,7 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: _models.ServerSecurityAlertPolicy, *, content_type: str = "application/json", @@ -220,7 +315,8 @@ async def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -245,7 +341,7 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: IO, *, content_type: str = "application/json", @@ -259,7 +355,8 @@ async def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -284,7 +381,7 @@ async def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: @@ -296,7 +393,8 @@ async def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Is either a ServerSecurityAlertPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or IO @@ -319,7 +417,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -364,85 +462,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerSecurityAlertPolicy"]: - """Get the server's threat detection policies. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerSecurityAlertPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py index f782c968ad31..1ef625f1b771 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_trust_certificates_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -81,7 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustCertificatesListResult] = kwargs.pop("cls", None) error_map = { @@ -108,7 +109,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -171,7 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) request = build_get_request( @@ -228,7 +240,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerTrustCertificate]] = kwargs.pop("cls", None) @@ -401,7 +413,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -461,7 +473,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -523,7 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 5877915d3c07..c51f7525288c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -61,6 +62,97 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerTrustGroup"]: + """Lists a server trust 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. Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :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 ServerTrustGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups" + } + @distributed_trace_async async def get( self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any @@ -90,7 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -147,7 +239,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerTrustGroup]] = kwargs.pop("cls", None) @@ -320,7 +412,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -380,7 +472,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -442,7 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -483,86 +575,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}" } - @distributed_trace - def list_by_location( - self, resource_group_name: str, location_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerTrustGroup"]: - """Lists a server trust 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. Required. - :type resource_group_name: str - :param location_name: The name of the region where the resource is located. Required. - :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 ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_location_request( - resource_group_name=resource_group_name, - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups" - } - @distributed_trace def list_by_instance( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any @@ -582,7 +594,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -609,7 +621,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 b474633ddf76..8040e587b8e0 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -55,7 +56,7 @@ def __init__(self, *args, **kwargs) -> None: def list_by_server( self, resource_group_name: str, server_name: str, **kwargs: Any ) -> AsyncIterable["_models.ServerUsage"]: - """Returns server usages. + """Gets server usages. :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. Required. @@ -70,7 +71,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -97,7 +98,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -108,7 +120,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(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) 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 e1e1156071fe..2029903f4b55 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -58,6 +59,99 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerVulnerabilityAssessment"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerVulnerabilityAssessment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/vulnerabilityAssessments" + } + @distributed_trace_async async def get( self, @@ -93,7 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -245,7 +339,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -334,7 +428,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -367,85 +461,3 @@ async def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServerVulnerabilityAssessment"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerVulnerabilityAssessment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/vulnerabilityAssessments" - } 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 b55e98f23ed1..6185cf9d5ea8 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -127,7 +128,7 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameAvailabilityResponse] = kwargs.pop("cls", None) @@ -188,7 +189,7 @@ def list(self, expand: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) error_map = { @@ -214,7 +215,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -265,7 +277,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) error_map = { @@ -292,7 +304,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -355,7 +378,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) request = build_get_request( @@ -407,7 +430,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Server]] = kwargs.pop("cls", None) @@ -566,7 +589,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -625,7 +648,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -682,7 +705,7 @@ async def begin_delete(self, resource_group_name: str, server_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -736,7 +759,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Server]] = kwargs.pop("cls", None) @@ -892,7 +915,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -955,7 +978,7 @@ async def _import_database_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -1115,7 +1138,7 @@ async def begin_import_database( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1174,7 +1197,7 @@ async def _refresh_status_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.RefreshExternalGovernanceStatusOperationResult]] = kwargs.pop("cls", None) request = build_refresh_status_request( @@ -1241,7 +1264,7 @@ async def begin_refresh_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RefreshExternalGovernanceStatusOperationResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 deleted file mode 100644 index 16d779e52963..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py +++ /dev/null @@ -1,200 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._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]] - - -class ServiceObjectivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.aio.SqlManagementClient`'s - :attr:`service_objectives` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get( - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param service_objective_name: The name of the service objective to retrieve. Required. - :type service_objective_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceObjective or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServiceObjective - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjective] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - service_objective_name=service_objective_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("ServiceObjective", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}" - } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ServiceObjective"]: - """Returns database service objectives. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServiceObjective or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.ServiceObjective] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjectiveListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/serviceObjectives" - } 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 fc1fbf72d61d..2b441d4f96ea 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 @@ -78,7 +78,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) request = build_get_request( @@ -207,7 +207,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py index 085143d859fc..c6d74aac5e20 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baseline_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -94,7 +95,7 @@ def list_by_sql_vulnerability_assessment( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -123,7 +124,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -202,7 +214,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py index e3200f1df96e..4d0d52c06316 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_baselines_operations.py @@ -184,7 +184,7 @@ async def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py index 6176f58ffc64..9984cdedceb2 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_execute_scan_operations.py @@ -78,7 +78,7 @@ async def _execute_initial( # pylint: disable=inconsistent-return-statements system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_execute_request( @@ -152,7 +152,7 @@ async def begin_execute( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py index 68e0c064fe13..af772895f8ed 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baseline_operations.py @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -99,7 +100,7 @@ def list_by_baseline( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -129,7 +130,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -211,7 +223,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -388,7 +400,7 @@ async def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py index 48ec6362b5c2..df29f78fc387 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_rule_baselines_operations.py @@ -101,7 +101,7 @@ async def delete( # pylint: disable=inconsistent-return-statements system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py index d54101581bd4..62de89146ed4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scan_result_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -99,7 +100,7 @@ def list_by_scan( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -129,7 +130,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -211,7 +223,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py index 4c180ae7d533..fa9cf25b162a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessment_scans_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -94,7 +95,7 @@ def list_by_sql_vulnerability_assessments( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -123,7 +124,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -200,7 +212,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py index 594917ecdd3b..9dfc99bdf80d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_operations.py @@ -84,7 +84,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py index b048f056130a..a8939ce2cde4 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sql_vulnerability_assessments_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -78,7 +79,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -105,7 +106,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -174,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -317,7 +329,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py index 791f7c72e994..ef2a4f50dd4d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_start_stop_managed_instance_schedules_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -79,7 +80,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StartStopManagedInstanceScheduleListResult] = kwargs.pop("cls", None) error_map = { @@ -106,7 +107,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -174,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) request = build_get_request( @@ -317,7 +329,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) @@ -405,7 +417,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 a79c15a5250e..b12276d4dabb 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -66,7 +67,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncIterable[" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -92,7 +93,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -150,7 +162,7 @@ async def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py index 4c3d1e928d8d..fbe8a299e722 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_synapse_link_workspaces_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -73,7 +74,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SynapseLinkWorkspaceListResult] = kwargs.pop("cls", None) error_map = { @@ -101,7 +102,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 e19cb88cefc8..24c084cd8379 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -62,6 +63,97 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SyncAgent"]: + """Lists sync agents in a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server on which the sync agent is hosted. Required. + :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 SyncAgent or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/syncAgents" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any @@ -91,7 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) request = build_get_request( @@ -148,7 +240,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncAgent]] = kwargs.pop("cls", None) @@ -321,7 +413,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -381,7 +473,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -443,7 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -484,86 +576,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SyncAgent"]: - """Lists sync agents in a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server on which the sync agent is hosted. Required. - :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 SyncAgent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/syncAgents" - } - @distributed_trace_async async def generate_key( self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any @@ -593,7 +605,7 @@ async def generate_key( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) request = build_generate_key_request( @@ -653,7 +665,7 @@ def list_linked_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgentLinkedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -681,7 +693,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 da7f60971dae..0cd8e929494a 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -85,7 +86,7 @@ def list_sync_database_ids( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncDatabaseIdListResult] = kwargs.pop("cls", None) error_map = { @@ -111,7 +112,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -145,132 +157,11 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds" } - async def _refresh_hub_schema_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_refresh_hub_schema_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, - api_version=api_version, - template_url=self._refresh_hub_schema_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _refresh_hub_schema_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" - } - - @distributed_trace_async - async def begin_refresh_hub_schema( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Refreshes a hub database schema. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :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. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._refresh_hub_schema_initial( # type: ignore - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_refresh_hub_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" - } - @distributed_trace - def list_hub_schemas( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SyncFullSchemaProperties"]: - """Gets a collection of hub database schemas. + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SyncGroup"]: + """Lists sync groups under a hub database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -279,20 +170,16 @@ def list_hub_schemas( :type server_name: str :param database_name: The name of the database on which the sync group is hosted. Required. :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :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 SyncFullSchemaProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :return: An iterator like instance of either SyncGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -305,14 +192,13 @@ def list_hub_schemas( def prepare_request(next_link=None): if not next_link: - request = build_list_hub_schemas_request( + request = build_list_by_database_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, api_version=api_version, - template_url=self.list_hub_schemas.metadata["url"], + template_url=self.list_by_database.metadata["url"], headers=_headers, params=_params, ) @@ -320,14 +206,25 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) 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("SyncGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -350,24 +247,15 @@ async def get_next(next_link=None): 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" + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups" } - @distributed_trace - def list_logs( - self, - 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 - ) -> AsyncIterable["_models.SyncGroupLogProperties"]: - """Gets a collection of sync group logs. + @distributed_trace_async + async def get( + self, 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -378,28 +266,11 @@ def list_logs( :type database_name: str :param sync_group_name: The name of the sync group. Required. :type sync_group_name: str - :param start_time: Get logs generated after this time. Required. - :type start_time: str - :param end_time: Get logs generated before this time. Required. - :type end_time: str - :param type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and - "Success". Required. - :type type: str or ~azure.mgmt.sql.models.SyncGroupsType - :param continuation_token_parameter: The continuation token for this operation. Default value - is None. - :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 SyncGroupLogProperties or the result of - cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :return: SyncGroup or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.SyncGroup :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -408,254 +279,38 @@ def list_logs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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, - api_version=api_version, - template_url=self.list_logs.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("SyncGroupLogListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if 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_logs.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" - } - - @distributed_trace_async - async def cancel_sync( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel_sync.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel_sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" - } - - @distributed_trace_async - async def trigger_sync( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.trigger_sync.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - trigger_sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync" - } - - @distributed_trace_async - async def get( - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SyncGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("SyncGroup", pipeline_response) + deserialized = self._deserialize("SyncGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -686,7 +341,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncGroup]] = kwargs.pop("cls", None) @@ -869,7 +524,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -930,7 +585,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -995,7 +650,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1057,7 +712,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncGroup]] = kwargs.pop("cls", None) @@ -1237,7 +892,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1284,11 +939,11 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SyncGroup"]: - """Lists sync groups under a hub database. + @distributed_trace_async + async def cancel_sync( # pylint: disable=inconsistent-return-statements + self, 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1297,17 +952,13 @@ def list_by_database( :type server_name: str :param database_name: The name of the database on which the sync group is hosted. Required. :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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 SyncGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroup] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1316,31 +967,117 @@ def list_by_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + 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, + api_version=api_version, + template_url=self.cancel_sync.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - async def extract_data(pipeline_response): - deserialized = self._deserialize("SyncGroupListResult", pipeline_response) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_sync.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" + } + + @distributed_trace + def list_hub_schemas( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SyncFullSchemaProperties"]: + """Gets a collection of hub database schemas. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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 SyncFullSchemaProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_hub_schemas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1363,6 +1100,314 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups" + list_hub_schemas.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas" + } + + @distributed_trace + def list_logs( + self, + 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 + ) -> AsyncIterable["_models.SyncGroupLogProperties"]: + """Gets a collection of sync group logs. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param start_time: Get logs generated after this time. Required. + :type start_time: str + :param end_time: Get logs generated before this time. Required. + :type end_time: str + :param type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and + "Success". Required. + :type type: str or ~azure.mgmt.sql.models.SyncGroupsType + :param continuation_token_parameter: The continuation token for this operation. Default value + is None. + :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 SyncGroupLogProperties or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_logs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_logs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" + } + + async def _refresh_hub_schema_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_refresh_hub_schema_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, + api_version=api_version, + template_url=self._refresh_hub_schema_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _refresh_hub_schema_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" + } + + @distributed_trace_async + async def begin_refresh_hub_schema( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refreshes a hub database schema. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_hub_schema_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh_hub_schema.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" + } + + @distributed_trace_async + async def trigger_sync( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :type sync_group_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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.trigger_sync.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + trigger_sync.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync" } 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 461e48e40fe8..62aaff26b617 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -63,6 +64,103 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_sync_group( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SyncMember"]: + """Lists sync members in the given sync 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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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 SyncMember or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_sync_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_sync_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers" + } + @distributed_trace_async async def get( self, @@ -103,7 +201,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) request = build_get_request( @@ -164,7 +262,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncMember]] = kwargs.pop("cls", None) @@ -360,7 +458,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -428,7 +526,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -503,7 +601,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -567,7 +665,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncMember]] = kwargs.pop("cls", None) @@ -760,7 +858,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -808,190 +906,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" } - @distributed_trace - def list_by_sync_group( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SyncMember"]: - """Lists sync members in the given sync 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :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 SyncMember or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_sync_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_sync_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers" - } - - @distributed_trace - def list_member_schemas( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SyncFullSchemaProperties"]: - """Gets a sync member database schema. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group on which the sync member is hosted. - Required. - :type sync_group_name: str - :param sync_member_name: The name of the sync member. Required. - :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 SyncFullSchemaProperties or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_member_schemas.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_member_schemas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas" - } - async def _refresh_member_schema_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, @@ -1012,7 +926,7 @@ async def _refresh_member_schema_initial( # pylint: disable=inconsistent-return _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_refresh_member_schema_request( @@ -1087,7 +1001,7 @@ async def begin_refresh_member_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1129,3 +1043,112 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_refresh_member_schema.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema" } + + @distributed_trace + def list_member_schemas( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.SyncFullSchemaProperties"]: + """Gets a sync member database schema. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group on which the sync member is hosted. + Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :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 SyncFullSchemaProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_member_schemas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_member_schemas.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas" + } 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 6eb199ba6652..c2d1e318169f 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 @@ -67,7 +67,7 @@ async def _create_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -214,7 +214,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 a354de855cfa..ae7d04cf5a42 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -66,7 +67,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> AsyncIterable[" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -92,7 +93,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -150,7 +162,7 @@ async def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) request = build_get_request( 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 9bfb2cde9706..8baf1f3b485f 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -83,7 +84,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryptionListResult] = kwargs.pop("cls", None) error_map = { @@ -111,7 +112,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -182,7 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) request = build_get_request( @@ -241,7 +253,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LogicalDatabaseTransparentDataEncryption]] = kwargs.pop("cls", None) @@ -430,7 +442,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 cbe42d0ae7db..da08a407290b 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -73,7 +74,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) error_map = { @@ -101,7 +102,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 e567f3b5b1d8..01b9b9818d6f 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -74,7 +75,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.VirtualCluster"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) error_map = { @@ -99,7 +100,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -148,7 +160,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) error_map = { @@ -174,7 +186,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -233,7 +256,7 @@ async def get(self, resource_group_name: str, virtual_cluster_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) request = build_get_request( @@ -284,7 +307,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -343,7 +366,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -401,7 +424,7 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.VirtualCluster]] = kwargs.pop("cls", None) @@ -561,7 +584,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -620,7 +643,7 @@ async def _update_dns_servers_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.UpdateVirtualClusterDnsServersOperation]] = kwargs.pop("cls", None) request = build_update_dns_servers_request( @@ -688,7 +711,7 @@ async def begin_update_dns_servers( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UpdateVirtualClusterDnsServersOperation] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 5f1bec7657b5..32ae70d8dafe 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,97 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetworkRule"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/virtualNetworkRules" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any @@ -89,7 +181,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) request = build_get_request( @@ -146,7 +238,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.VirtualNetworkRule]] = kwargs.pop("cls", None) @@ -319,7 +411,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -379,7 +471,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -441,7 +533,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -481,83 +573,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualNetworkRule"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/virtualNetworkRules" - } 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 1d92106e2b4b..02a735b62081 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,104 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_workload_group( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadClassifier"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param workload_group_name: The name of the workload group from which to receive the + classifiers from. Required. + :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 WorkloadClassifier or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_workload_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_workload_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers" + } + @distributed_trace_async async def get( self, @@ -100,7 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) request = build_get_request( @@ -161,7 +260,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.WorkloadClassifier]] = kwargs.pop("cls", None) @@ -360,7 +459,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -428,7 +527,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -503,7 +602,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -545,90 +644,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" } - - @distributed_trace - def list_by_workload_group( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkloadClassifier"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param workload_group_name: The name of the workload group from which to receive the - classifiers from. Required. - :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 WorkloadClassifier or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_workload_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_workload_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers" - } 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 5edb044cbd1d..e38df861a905 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -60,6 +61,100 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadGroup"]: + """Gets the list of workload groups. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 WorkloadGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any @@ -91,7 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -150,7 +245,7 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.WorkloadGroup]] = kwargs.pop("cls", None) @@ -333,7 +428,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -394,7 +489,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -459,7 +554,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -500,86 +595,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> AsyncIterable["_models.WorkloadGroup"]: - """Gets the list of workload groups. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 WorkloadGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups" - } 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 8e34c3cfa2dc..92ec37528aa1 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 @@ -17,6 +17,8 @@ from ._models_py3 import Baseline from ._models_py3 import BaselineAdjustedResult from ._models_py3 import BenchmarkReference +from ._models_py3 import CertificateInfo +from ._models_py3 import ChangeLongTermRetentionBackupAccessTierParameters from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResponse from ._models_py3 import CompleteDatabaseRestoreDefinition @@ -65,13 +67,11 @@ from ._models_py3 import DeletedServer from ._models_py3 import DeletedServerListResult from ._models_py3 import DistributedAvailabilityGroup +from ._models_py3 import DistributedAvailabilityGroupDatabase +from ._models_py3 import DistributedAvailabilityGroupSetRole from ._models_py3 import DistributedAvailabilityGroupsListResult 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 @@ -87,6 +87,9 @@ from ._models_py3 import EndpointCertificateListResult from ._models_py3 import EndpointDependency from ._models_py3 import EndpointDetail +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse from ._models_py3 import ExportDatabaseDefinition from ._models_py3 import ExtendedDatabaseBlobAuditingPolicy from ._models_py3 import ExtendedDatabaseBlobAuditingPolicyListResult @@ -100,6 +103,7 @@ from ._models_py3 import FirewallRule from ._models_py3 import FirewallRuleList from ._models_py3 import FirewallRuleListResult +from ._models_py3 import FreeLimitExhaustionBehaviorCapability from ._models_py3 import GeoBackupPolicy from ._models_py3 import GeoBackupPolicyListResult from ._models_py3 import IPv6FirewallRule @@ -121,14 +125,21 @@ from ._models_py3 import InstancePoolVcoresCapability from ._models_py3 import Job from ._models_py3 import JobAgent +from ._models_py3 import JobAgentEditionCapability +from ._models_py3 import JobAgentIdentity from ._models_py3 import JobAgentListResult +from ._models_py3 import JobAgentServiceLevelObjectiveCapability from ._models_py3 import JobAgentUpdate +from ._models_py3 import JobAgentUserAssignedIdentity +from ._models_py3 import JobAgentVersionCapability 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 JobPrivateEndpoint +from ._models_py3 import JobPrivateEndpointListResult from ._models_py3 import JobSchedule from ._models_py3 import JobStep from ._models_py3 import JobStepAction @@ -229,22 +240,24 @@ from ._models_py3 import ManagedServerSecurityAlertPolicyListResult from ._models_py3 import ManagedTransparentDataEncryption from ._models_py3 import ManagedTransparentDataEncryptionListResult +from ._models_py3 import MaxLimitRangeCapability 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 NSPConfigAccessRule +from ._models_py3 import NSPConfigAccessRuleProperties +from ._models_py3 import NSPConfigAssociation +from ._models_py3 import NSPConfigNetworkSecurityPerimeterRule +from ._models_py3 import NSPConfigPerimeter +from ._models_py3 import NSPConfigProfile +from ._models_py3 import NSPProvisioningIssue +from ._models_py3 import NSPProvisioningIssueProperties from ._models_py3 import Name from ._models_py3 import NetworkIsolationSettings -from ._models_py3 import NetworkIsolationSettingsAutoGenerated +from ._models_py3 import NetworkSecurityPerimeterConfiguration +from ._models_py3 import NetworkSecurityPerimeterConfigurationListResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay -from ._models_py3 import OperationImpact from ._models_py3 import OperationListResult from ._models_py3 import OutboundEnvironmentEndpoint from ._models_py3 import OutboundEnvironmentEndpointCollection @@ -252,7 +265,9 @@ from ._models_py3 import OutboundFirewallRuleListResult from ._models_py3 import PartnerInfo from ._models_py3 import PartnerRegionInfo +from ._models_py3 import PerDatabaseAutoPauseDelayTimeRange from ._models_py3 import PerformanceLevelCapability +from ._models_py3 import PhaseDetails from ._models_py3 import PrivateEndpointConnection from ._models_py3 import PrivateEndpointConnectionListResult from ._models_py3 import PrivateEndpointConnectionProperties @@ -266,6 +281,7 @@ from ._models_py3 import ProxyResourceWithWritableName from ._models_py3 import QueryCheck from ._models_py3 import QueryMetricInterval +from ._models_py3 import QueryMetricIntervalAutoGenerated from ._models_py3 import QueryMetricProperties from ._models_py3 import QueryStatistics from ._models_py3 import QueryStatisticsProperties @@ -283,6 +299,7 @@ from ._models_py3 import RecoverableManagedDatabase from ._models_py3 import RecoverableManagedDatabaseListResult from ._models_py3 import RefreshExternalGovernanceStatusOperationResult +from ._models_py3 import RefreshExternalGovernanceStatusOperationResultMI from ._models_py3 import Remediation from ._models_py3 import ReplicationLink from ._models_py3 import ReplicationLinkListResult @@ -313,8 +330,6 @@ 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 ServerConfigurationOption from ._models_py3 import ServerConfigurationOptionListResult from ._models_py3 import ServerConnectionPolicy @@ -343,12 +358,9 @@ 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 SqlVulnerabilityAssessment from ._models_py3 import SqlVulnerabilityAssessmentListResult @@ -394,7 +406,7 @@ from ._models_py3 import UpdateLongTermRetentionBackupParameters from ._models_py3 import UpdateVirtualClusterDnsServersOperation from ._models_py3 import UpsertManagedServerOperationParameters -from ._models_py3 import UpsertManagedServerOperationStep +from ._models_py3 import UpsertManagedServerOperationStepWithEstimatesAndDuration from ._models_py3 import Usage from ._models_py3 import UsageListResult from ._models_py3 import UserIdentity @@ -420,6 +432,7 @@ from ._sql_management_client_enums import AdvisorStatus from ._sql_management_client_enums import AggregationFunctionType from ._sql_management_client_enums import AlwaysEncryptedEnclaveType +from ._sql_management_client_enums import AuthMetadataLookupModes from ._sql_management_client_enums import AuthenticationName from ._sql_management_client_enums import AutoExecuteStatus from ._sql_management_client_enums import AutoExecuteStatusInheritedFrom @@ -430,6 +443,7 @@ from ._sql_management_client_enums import AutomaticTuningServerMode from ._sql_management_client_enums import AutomaticTuningServerReason from ._sql_management_client_enums import AvailabilityZoneType +from ._sql_management_client_enums import BackupStorageAccessTier from ._sql_management_client_enums import BackupStorageRedundancy from ._sql_management_client_enums import BaselineName from ._sql_management_client_enums import BlobAuditingPolicyState @@ -437,12 +451,14 @@ from ._sql_management_client_enums import CapabilityStatus from ._sql_management_client_enums import CatalogCollationType from ._sql_management_client_enums import CheckNameAvailabilityReason +from ._sql_management_client_enums import ClientClassificationSource from ._sql_management_client_enums import ColumnDataType from ._sql_management_client_enums import ConnectionPolicyName from ._sql_management_client_enums import CreateMode from ._sql_management_client_enums import CreatedByType from ._sql_management_client_enums import DNSRefreshOperationStatus from ._sql_management_client_enums import DataMaskingFunction +from ._sql_management_client_enums import DataMaskingPolicyName from ._sql_management_client_enums import DataMaskingRuleState from ._sql_management_client_enums import DataMaskingState from ._sql_management_client_enums import DataWarehouseUserActivityName @@ -461,14 +477,20 @@ from ._sql_management_client_enums import EncryptionProtectorName from ._sql_management_client_enums import ExternalGovernanceStatus from ._sql_management_client_enums import FailoverGroupReplicationRole +from ._sql_management_client_enums import FailoverModeType from ._sql_management_client_enums import FreeLimitExhaustionBehavior +from ._sql_management_client_enums import FreemiumType from ._sql_management_client_enums import GeoBackupPolicyName from ._sql_management_client_enums import GeoBackupPolicyState +from ._sql_management_client_enums import HybridSecondaryUsage +from ._sql_management_client_enums import HybridSecondaryUsageDetected from ._sql_management_client_enums import IdentityType from ._sql_management_client_enums import ImplementationMethod from ._sql_management_client_enums import InstanceFailoverGroupReplicationRole from ._sql_management_client_enums import InstancePoolLicenseType +from ._sql_management_client_enums import InstanceRole from ._sql_management_client_enums import IsRetryable +from ._sql_management_client_enums import JobAgentIdentityType from ._sql_management_client_enums import JobAgentState from ._sql_management_client_enums import JobExecutionLifecycle from ._sql_management_client_enums import JobScheduleType @@ -479,14 +501,15 @@ from ._sql_management_client_enums import JobTargetType from ._sql_management_client_enums import LedgerDigestUploadsName from ._sql_management_client_enums import LedgerDigestUploadsState +from ._sql_management_client_enums import LinkRole from ._sql_management_client_enums import LogSizeUnit from ._sql_management_client_enums import LongTermRetentionPolicyName from ._sql_management_client_enums import ManagedDatabaseCreateMode from ._sql_management_client_enums import ManagedDatabaseStatus from ._sql_management_client_enums import ManagedInstanceAdministratorType +from ._sql_management_client_enums import ManagedInstanceDatabaseFormat from ._sql_management_client_enums import ManagedInstanceLicenseType from ._sql_management_client_enums import ManagedInstanceLongTermRetentionPolicyName -from ._sql_management_client_enums import ManagedInstancePropertiesProvisioningState from ._sql_management_client_enums import ManagedInstanceProxyOverride from ._sql_management_client_enums import ManagedLedgerDigestUploadsName from ._sql_management_client_enums import ManagedLedgerDigestUploadsState @@ -500,7 +523,7 @@ from ._sql_management_client_enums import OperationOrigin from ._sql_management_client_enums import PauseDelayTimeUnit from ._sql_management_client_enums import PerformanceLevelUnit -from ._sql_management_client_enums import PrimaryAggregationType +from ._sql_management_client_enums import Phase from ._sql_management_client_enums import PrincipalType from ._sql_management_client_enums import PrivateEndpointProvisioningState from ._sql_management_client_enums import PrivateLinkServiceConnectionStateActionsRequire @@ -513,13 +536,16 @@ from ._sql_management_client_enums import RecommendedActionCurrentState from ._sql_management_client_enums import RecommendedActionInitiatedBy from ._sql_management_client_enums import RecommendedSensitivityLabelUpdateKind +from ._sql_management_client_enums import ReplicaConnectedState +from ._sql_management_client_enums import ReplicaSynchronizationHealth from ._sql_management_client_enums import ReplicaType from ._sql_management_client_enums import ReplicationLinkType -from ._sql_management_client_enums import ReplicationMode +from ._sql_management_client_enums import ReplicationModeType from ._sql_management_client_enums import ReplicationRole from ._sql_management_client_enums import ReplicationState from ._sql_management_client_enums import RestoreDetailsName from ._sql_management_client_enums import RestorePointType +from ._sql_management_client_enums import RoleChangeType from ._sql_management_client_enums import RuleSeverity from ._sql_management_client_enums import RuleStatus from ._sql_management_client_enums import RuleType @@ -527,9 +553,11 @@ from ._sql_management_client_enums import SecondaryInstanceType from ._sql_management_client_enums import SecondaryType from ._sql_management_client_enums import SecurityAlertPolicyName +from ._sql_management_client_enums import SecurityAlertPolicyNameAutoGenerated from ._sql_management_client_enums import SecurityAlertPolicyState from ._sql_management_client_enums import SecurityAlertsPolicyState from ._sql_management_client_enums import SecurityEventType +from ._sql_management_client_enums import SeedingModeType from ._sql_management_client_enums import SensitivityLabelRank from ._sql_management_client_enums import SensitivityLabelSource from ._sql_management_client_enums import SensitivityLabelUpdateKind @@ -540,13 +568,13 @@ from ._sql_management_client_enums import ServerPublicNetworkAccessFlag from ._sql_management_client_enums import ServerTrustGroupPropertiesTrustScopesItem from ._sql_management_client_enums import ServerWorkspaceFeature -from ._sql_management_client_enums import ServiceObjectiveName from ._sql_management_client_enums import ServicePrincipalType from ._sql_management_client_enums import ShortTermRetentionPolicyName from ._sql_management_client_enums import SqlAgentConfigurationPropertiesState from ._sql_management_client_enums import SqlVulnerabilityAssessmentName from ._sql_management_client_enums import SqlVulnerabilityAssessmentState from ._sql_management_client_enums import StartStopScheduleName +from ._sql_management_client_enums import Status from ._sql_management_client_enums import StorageCapabilityStorageAccountType from ._sql_management_client_enums import StorageKeyType from ._sql_management_client_enums import SyncAgentState @@ -560,9 +588,6 @@ from ._sql_management_client_enums import TableTemporalType from ._sql_management_client_enums import TransparentDataEncryptionName from ._sql_management_client_enums import TransparentDataEncryptionState -from ._sql_management_client_enums import UnitDefinitionType -from ._sql_management_client_enums import UnitType -from ._sql_management_client_enums import UpsertManagedServerOperationStepStatus from ._sql_management_client_enums import VirtualNetworkRuleState from ._sql_management_client_enums import VulnerabilityAssessmentName from ._sql_management_client_enums import VulnerabilityAssessmentPolicyBaselineName @@ -584,6 +609,8 @@ "Baseline", "BaselineAdjustedResult", "BenchmarkReference", + "CertificateInfo", + "ChangeLongTermRetentionBackupAccessTierParameters", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "CompleteDatabaseRestoreDefinition", @@ -632,13 +659,11 @@ "DeletedServer", "DeletedServerListResult", "DistributedAvailabilityGroup", + "DistributedAvailabilityGroupDatabase", + "DistributedAvailabilityGroupSetRole", "DistributedAvailabilityGroupsListResult", "EditionCapability", "ElasticPool", - "ElasticPoolActivity", - "ElasticPoolActivityListResult", - "ElasticPoolDatabaseActivity", - "ElasticPoolDatabaseActivityListResult", "ElasticPoolEditionCapability", "ElasticPoolListResult", "ElasticPoolOperation", @@ -654,6 +679,9 @@ "EndpointCertificateListResult", "EndpointDependency", "EndpointDetail", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ExportDatabaseDefinition", "ExtendedDatabaseBlobAuditingPolicy", "ExtendedDatabaseBlobAuditingPolicyListResult", @@ -667,6 +695,7 @@ "FirewallRule", "FirewallRuleList", "FirewallRuleListResult", + "FreeLimitExhaustionBehaviorCapability", "GeoBackupPolicy", "GeoBackupPolicyListResult", "IPv6FirewallRule", @@ -688,14 +717,21 @@ "InstancePoolVcoresCapability", "Job", "JobAgent", + "JobAgentEditionCapability", + "JobAgentIdentity", "JobAgentListResult", + "JobAgentServiceLevelObjectiveCapability", "JobAgentUpdate", + "JobAgentUserAssignedIdentity", + "JobAgentVersionCapability", "JobCredential", "JobCredentialListResult", "JobExecution", "JobExecutionListResult", "JobExecutionTarget", "JobListResult", + "JobPrivateEndpoint", + "JobPrivateEndpointListResult", "JobSchedule", "JobStep", "JobStepAction", @@ -796,22 +832,24 @@ "ManagedServerSecurityAlertPolicyListResult", "ManagedTransparentDataEncryption", "ManagedTransparentDataEncryptionListResult", + "MaxLimitRangeCapability", "MaxSizeCapability", "MaxSizeRangeCapability", - "Metric", - "MetricAvailability", - "MetricDefinition", - "MetricDefinitionListResult", - "MetricListResult", - "MetricName", - "MetricValue", "MinCapacityCapability", + "NSPConfigAccessRule", + "NSPConfigAccessRuleProperties", + "NSPConfigAssociation", + "NSPConfigNetworkSecurityPerimeterRule", + "NSPConfigPerimeter", + "NSPConfigProfile", + "NSPProvisioningIssue", + "NSPProvisioningIssueProperties", "Name", "NetworkIsolationSettings", - "NetworkIsolationSettingsAutoGenerated", + "NetworkSecurityPerimeterConfiguration", + "NetworkSecurityPerimeterConfigurationListResult", "Operation", "OperationDisplay", - "OperationImpact", "OperationListResult", "OutboundEnvironmentEndpoint", "OutboundEnvironmentEndpointCollection", @@ -819,7 +857,9 @@ "OutboundFirewallRuleListResult", "PartnerInfo", "PartnerRegionInfo", + "PerDatabaseAutoPauseDelayTimeRange", "PerformanceLevelCapability", + "PhaseDetails", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", "PrivateEndpointConnectionProperties", @@ -833,6 +873,7 @@ "ProxyResourceWithWritableName", "QueryCheck", "QueryMetricInterval", + "QueryMetricIntervalAutoGenerated", "QueryMetricProperties", "QueryStatistics", "QueryStatisticsProperties", @@ -850,6 +891,7 @@ "RecoverableManagedDatabase", "RecoverableManagedDatabaseListResult", "RefreshExternalGovernanceStatusOperationResult", + "RefreshExternalGovernanceStatusOperationResultMI", "Remediation", "ReplicationLink", "ReplicationLinkListResult", @@ -880,8 +922,6 @@ "ServerAzureADOnlyAuthentication", "ServerBlobAuditingPolicy", "ServerBlobAuditingPolicyListResult", - "ServerCommunicationLink", - "ServerCommunicationLinkListResult", "ServerConfigurationOption", "ServerConfigurationOptionListResult", "ServerConnectionPolicy", @@ -910,12 +950,9 @@ "ServerVersionCapability", "ServerVulnerabilityAssessment", "ServerVulnerabilityAssessmentListResult", - "ServiceObjective", "ServiceObjectiveCapability", - "ServiceObjectiveListResult", "ServicePrincipal", "Sku", - "SloUsageMetric", "SqlAgentConfiguration", "SqlVulnerabilityAssessment", "SqlVulnerabilityAssessmentListResult", @@ -961,7 +998,7 @@ "UpdateLongTermRetentionBackupParameters", "UpdateVirtualClusterDnsServersOperation", "UpsertManagedServerOperationParameters", - "UpsertManagedServerOperationStep", + "UpsertManagedServerOperationStepWithEstimatesAndDuration", "Usage", "UsageListResult", "UserIdentity", @@ -986,6 +1023,7 @@ "AdvisorStatus", "AggregationFunctionType", "AlwaysEncryptedEnclaveType", + "AuthMetadataLookupModes", "AuthenticationName", "AutoExecuteStatus", "AutoExecuteStatusInheritedFrom", @@ -996,6 +1034,7 @@ "AutomaticTuningServerMode", "AutomaticTuningServerReason", "AvailabilityZoneType", + "BackupStorageAccessTier", "BackupStorageRedundancy", "BaselineName", "BlobAuditingPolicyState", @@ -1003,12 +1042,14 @@ "CapabilityStatus", "CatalogCollationType", "CheckNameAvailabilityReason", + "ClientClassificationSource", "ColumnDataType", "ConnectionPolicyName", "CreateMode", "CreatedByType", "DNSRefreshOperationStatus", "DataMaskingFunction", + "DataMaskingPolicyName", "DataMaskingRuleState", "DataMaskingState", "DataWarehouseUserActivityName", @@ -1027,14 +1068,20 @@ "EncryptionProtectorName", "ExternalGovernanceStatus", "FailoverGroupReplicationRole", + "FailoverModeType", "FreeLimitExhaustionBehavior", + "FreemiumType", "GeoBackupPolicyName", "GeoBackupPolicyState", + "HybridSecondaryUsage", + "HybridSecondaryUsageDetected", "IdentityType", "ImplementationMethod", "InstanceFailoverGroupReplicationRole", "InstancePoolLicenseType", + "InstanceRole", "IsRetryable", + "JobAgentIdentityType", "JobAgentState", "JobExecutionLifecycle", "JobScheduleType", @@ -1045,14 +1092,15 @@ "JobTargetType", "LedgerDigestUploadsName", "LedgerDigestUploadsState", + "LinkRole", "LogSizeUnit", "LongTermRetentionPolicyName", "ManagedDatabaseCreateMode", "ManagedDatabaseStatus", "ManagedInstanceAdministratorType", + "ManagedInstanceDatabaseFormat", "ManagedInstanceLicenseType", "ManagedInstanceLongTermRetentionPolicyName", - "ManagedInstancePropertiesProvisioningState", "ManagedInstanceProxyOverride", "ManagedLedgerDigestUploadsName", "ManagedLedgerDigestUploadsState", @@ -1066,7 +1114,7 @@ "OperationOrigin", "PauseDelayTimeUnit", "PerformanceLevelUnit", - "PrimaryAggregationType", + "Phase", "PrincipalType", "PrivateEndpointProvisioningState", "PrivateLinkServiceConnectionStateActionsRequire", @@ -1079,13 +1127,16 @@ "RecommendedActionCurrentState", "RecommendedActionInitiatedBy", "RecommendedSensitivityLabelUpdateKind", + "ReplicaConnectedState", + "ReplicaSynchronizationHealth", "ReplicaType", "ReplicationLinkType", - "ReplicationMode", + "ReplicationModeType", "ReplicationRole", "ReplicationState", "RestoreDetailsName", "RestorePointType", + "RoleChangeType", "RuleSeverity", "RuleStatus", "RuleType", @@ -1093,9 +1144,11 @@ "SecondaryInstanceType", "SecondaryType", "SecurityAlertPolicyName", + "SecurityAlertPolicyNameAutoGenerated", "SecurityAlertPolicyState", "SecurityAlertsPolicyState", "SecurityEventType", + "SeedingModeType", "SensitivityLabelRank", "SensitivityLabelSource", "SensitivityLabelUpdateKind", @@ -1106,13 +1159,13 @@ "ServerPublicNetworkAccessFlag", "ServerTrustGroupPropertiesTrustScopesItem", "ServerWorkspaceFeature", - "ServiceObjectiveName", "ServicePrincipalType", "ShortTermRetentionPolicyName", "SqlAgentConfigurationPropertiesState", "SqlVulnerabilityAssessmentName", "SqlVulnerabilityAssessmentState", "StartStopScheduleName", + "Status", "StorageCapabilityStorageAccountType", "StorageKeyType", "SyncAgentState", @@ -1126,9 +1179,6 @@ "TableTemporalType", "TransparentDataEncryptionName", "TransparentDataEncryptionState", - "UnitDefinitionType", - "UnitType", - "UpsertManagedServerOperationStepStatus", "VirtualNetworkRuleState", "VulnerabilityAssessmentName", "VulnerabilityAssessmentPolicyBaselineName", 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 ffe8658d9c0f..13aecf690316 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 @@ -544,6 +544,71 @@ def __init__(self, **kwargs: Any) -> None: self.reference = None +class CertificateInfo(_serialization.Model): + """Certificate information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar certificate_name: The certificate name. + :vartype certificate_name: str + :ivar expiry_date: The certificate expiry date. + :vartype expiry_date: ~datetime.datetime + """ + + _validation = { + "certificate_name": {"readonly": True}, + "expiry_date": {"readonly": True}, + } + + _attribute_map = { + "certificate_name": {"key": "certificateName", "type": "str"}, + "expiry_date": {"key": "expiryDate", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.certificate_name = None + self.expiry_date = None + + +class ChangeLongTermRetentionBackupAccessTierParameters(_serialization.Model): + """Contains the information necessary to change long term retention backup access tier and related + operation mode. + + All required parameters must be populated in order to send to Azure. + + :ivar backup_storage_access_tier: The long term retention backup storage access tier. Required. + :vartype backup_storage_access_tier: str + :ivar operation_mode: The operation mode when updating ltr backup storage access tier. + Required. + :vartype operation_mode: str + """ + + _validation = { + "backup_storage_access_tier": {"required": True}, + "operation_mode": {"required": True}, + } + + _attribute_map = { + "backup_storage_access_tier": {"key": "backupStorageAccessTier", "type": "str"}, + "operation_mode": {"key": "operationMode", "type": "str"}, + } + + def __init__(self, *, backup_storage_access_tier: str, operation_mode: str, **kwargs: Any) -> None: + """ + :keyword backup_storage_access_tier: The long term retention backup storage access tier. + Required. + :paramtype backup_storage_access_tier: str + :keyword operation_mode: The operation mode when updating ltr backup storage access tier. + Required. + :paramtype operation_mode: str + """ + super().__init__(**kwargs) + self.backup_storage_access_tier = backup_storage_access_tier + self.operation_mode = operation_mode + + class CheckNameAvailabilityRequest(_serialization.Model): """A request to check whether the specified name for a resource is available. @@ -2017,8 +2082,8 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class DatabaseExtensions(ProxyResource): - """An export managed database operation result resource. +class DatabaseExtensions(ProxyResource): # pylint: disable=too-many-instance-attributes + """An Import, Export, or PolybaseImport resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2028,15 +2093,33 @@ class DatabaseExtensions(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar operation_mode: Operation Mode. "PolybaseImport" + :ivar operation_mode: Operation mode of the operation: Import, Export, or PolybaseImport. Known + values are: "PolybaseImport", "Import", "Export", and "Import". :vartype operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :ivar storage_key_type: Storage key type. Known values are: "SharedAccessKey" and - "StorageAccessKey". + :ivar storage_key_type: Storage key type: StorageAccessKey or SharedAccessKey. Known values + are: "SharedAccessKey" and "StorageAccessKey". :vartype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :ivar storage_key: Storage key. + :ivar storage_key: Storage key for the storage account. :vartype storage_key: str - :ivar storage_uri: Storage Uri. + :ivar storage_uri: Storage Uri for the storage account. :vartype storage_uri: str + :ivar administrator_login: Administrator login name. + :vartype administrator_login: str + :ivar administrator_login_password: Administrator login password. + :vartype administrator_login_password: str + :ivar authentication_type: Authentication type: SQL authentication or AD password. + :vartype authentication_type: str + :ivar database_edition: Database edition for the newly created database in the case of an + import operation. + :vartype database_edition: str + :ivar service_objective_name: Database service level objective for the newly created database + in the case of an import operation. + :vartype service_objective_name: str + :ivar max_size_bytes: Database max size in bytes for the newly created database in the case of + an import operation. + :vartype max_size_bytes: str + :ivar network_isolation: Optional resource information to enable network isolation for request. + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ _validation = { @@ -2053,6 +2136,13 @@ class DatabaseExtensions(ProxyResource): "storage_key_type": {"key": "properties.storageKeyType", "type": "str"}, "storage_key": {"key": "properties.storageKey", "type": "str"}, "storage_uri": {"key": "properties.storageUri", "type": "str"}, + "administrator_login": {"key": "properties.administratorLogin", "type": "str"}, + "administrator_login_password": {"key": "properties.administratorLoginPassword", "type": "str"}, + "authentication_type": {"key": "properties.authenticationType", "type": "str"}, + "database_edition": {"key": "properties.databaseEdition", "type": "str"}, + "service_objective_name": {"key": "properties.serviceObjectiveName", "type": "str"}, + "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "str"}, + "network_isolation": {"key": "properties.networkIsolation", "type": "NetworkIsolationSettings"}, } def __init__( @@ -2062,24 +2152,57 @@ def __init__( storage_key_type: Optional[Union[str, "_models.StorageKeyType"]] = None, storage_key: Optional[str] = None, storage_uri: Optional[str] = None, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + authentication_type: Optional[str] = None, + database_edition: Optional[str] = None, + service_objective_name: Optional[str] = None, + max_size_bytes: Optional[str] = None, + network_isolation: Optional["_models.NetworkIsolationSettings"] = None, **kwargs: Any ) -> None: """ - :keyword operation_mode: Operation Mode. "PolybaseImport" + :keyword operation_mode: Operation mode of the operation: Import, Export, or PolybaseImport. + Known values are: "PolybaseImport", "Import", "Export", and "Import". :paramtype operation_mode: str or ~azure.mgmt.sql.models.OperationMode - :keyword storage_key_type: Storage key type. Known values are: "SharedAccessKey" and - "StorageAccessKey". + :keyword storage_key_type: Storage key type: StorageAccessKey or SharedAccessKey. Known values + are: "SharedAccessKey" and "StorageAccessKey". :paramtype storage_key_type: str or ~azure.mgmt.sql.models.StorageKeyType - :keyword storage_key: Storage key. + :keyword storage_key: Storage key for the storage account. :paramtype storage_key: str - :keyword storage_uri: Storage Uri. + :keyword storage_uri: Storage Uri for the storage account. :paramtype storage_uri: str + :keyword administrator_login: Administrator login name. + :paramtype administrator_login: str + :keyword administrator_login_password: Administrator login password. + :paramtype administrator_login_password: str + :keyword authentication_type: Authentication type: SQL authentication or AD password. + :paramtype authentication_type: str + :keyword database_edition: Database edition for the newly created database in the case of an + import operation. + :paramtype database_edition: str + :keyword service_objective_name: Database service level objective for the newly created + database in the case of an import operation. + :paramtype service_objective_name: str + :keyword max_size_bytes: Database max size in bytes for the newly created database in the case + of an import operation. + :paramtype max_size_bytes: str + :keyword network_isolation: Optional resource information to enable network isolation for + request. + :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ super().__init__(**kwargs) self.operation_mode = operation_mode self.storage_key_type = storage_key_type self.storage_key = storage_key self.storage_uri = storage_uri + self.administrator_login = administrator_login + self.administrator_login_password = administrator_login_password + self.authentication_type = authentication_type + self.database_edition = database_edition + self.service_objective_name = service_objective_name + self.max_size_bytes = max_size_bytes + self.network_isolation = network_isolation class DatabaseIdentity(_serialization.Model): @@ -2230,6 +2353,8 @@ class DatabaseOperation(ProxyResource): # pylint: disable=too-many-instance-att :vartype description: str :ivar is_cancellable: Whether the operation can be cancelled. :vartype is_cancellable: bool + :ivar operation_phase_details: The operation phase details. + :vartype operation_phase_details: ~azure.mgmt.sql.models.PhaseDetails """ _validation = { @@ -2250,6 +2375,7 @@ class DatabaseOperation(ProxyResource): # pylint: disable=too-many-instance-att "estimated_completion_time": {"readonly": True}, "description": {"readonly": True}, "is_cancellable": {"readonly": True}, + "operation_phase_details": {"readonly": True}, } _attribute_map = { @@ -2270,6 +2396,7 @@ class DatabaseOperation(ProxyResource): # pylint: disable=too-many-instance-att "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, "description": {"key": "properties.description", "type": "str"}, "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, + "operation_phase_details": {"key": "properties.operationPhaseDetails", "type": "PhaseDetails"}, } def __init__(self, **kwargs: Any) -> None: @@ -2289,6 +2416,7 @@ def __init__(self, **kwargs: Any) -> None: self.estimated_completion_time = None self.description = None self.is_cancellable = None + self.operation_phase_details = None class DatabaseOperationListResult(_serialization.Model): @@ -3478,11 +3606,13 @@ class DatabaseVulnerabilityAssessment(ProxyResource): :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. + isn't specified, StorageContainerSasKey is required. Applies only if the storage account is not + behind a Vnet or a firewall. :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. + storageAccountAccessKey is required. Applies only if the storage account is not behind a Vnet + or a firewall. :vartype storage_account_access_key: str :ivar recurring_scans: The recurring scans settings. :vartype recurring_scans: @@ -3524,11 +3654,13 @@ def __init__( :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. + '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. + 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: @@ -3679,7 +3811,7 @@ def __init__(self, **kwargs: Any) -> None: class DataMaskingPolicy(ProxyResource): - """Represents a database data masking policy. + """A database data masking policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -3691,10 +3823,10 @@ class DataMaskingPolicy(ProxyResource): :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. + :ivar kind: The kind of Data Masking Policy. Metadata, used for Azure portal. :vartype kind: str - :ivar data_masking_state: The state of the data masking policy. Known values are: "Disabled" - and "Enabled". + :ivar data_masking_state: The state of the data masking policy. Known values are: "Enabled" and + "Disabled". :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 @@ -3737,8 +3869,8 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword data_masking_state: The state of the data masking policy. Known values are: "Disabled" - and "Enabled". + :keyword data_masking_state: The state of the data masking policy. Known values are: "Enabled" + and "Disabled". :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. @@ -3755,7 +3887,7 @@ def __init__( class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attributes - """Represents a database data masking rule. + """A database data masking rule. Variables are only populated by the server, and will be ignored when sending a request. @@ -3771,13 +3903,11 @@ class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attri :vartype kind: str :ivar id_properties_id: The rule Id. :vartype id_properties_id: str - :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. Known values are: "Disabled" and - "Enabled". + enabled, regardless of the provided value of ruleState. Known values are: "Enabled" and + "Disabled". :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 @@ -3785,6 +3915,8 @@ class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attri :vartype table_name: str :ivar column_name: The column name on which the data masking rule is applied. :vartype column_name: str + :ivar alias_name: The alias name. This is a legacy parameter and is no longer used. + :vartype alias_name: str :ivar masking_function: The masking function that is used for the data masking rule. Known values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". :vartype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction @@ -3821,11 +3953,11 @@ class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attri "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"}, + "alias_name": {"key": "properties.aliasName", "type": "str"}, "masking_function": {"key": "properties.maskingFunction", "type": "str"}, "number_from": {"key": "properties.numberFrom", "type": "str"}, "number_to": {"key": "properties.numberTo", "type": "str"}, @@ -3837,11 +3969,11 @@ class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attri def __init__( self, *, - alias_name: Optional[str] = None, rule_state: Optional[Union[str, "_models.DataMaskingRuleState"]] = None, schema_name: Optional[str] = None, table_name: Optional[str] = None, column_name: Optional[str] = None, + alias_name: Optional[str] = None, masking_function: Optional[Union[str, "_models.DataMaskingFunction"]] = None, number_from: Optional[str] = None, number_to: Optional[str] = None, @@ -3851,13 +3983,11 @@ def __init__( **kwargs: Any ) -> None: """ - :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. Known values are: "Disabled" and - "Enabled". + enabled, regardless of the provided value of ruleState. Known values are: "Enabled" and + "Disabled". :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 @@ -3865,6 +3995,8 @@ def __init__( :paramtype table_name: str :keyword column_name: The column name on which the data masking rule is applied. :paramtype column_name: str + :keyword alias_name: The alias name. This is a legacy parameter and is no longer used. + :paramtype alias_name: str :keyword masking_function: The masking function that is used for the data masking rule. Known values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". :paramtype masking_function: str or ~azure.mgmt.sql.models.DataMaskingFunction @@ -3888,11 +4020,11 @@ def __init__( self.location = None self.kind = None self.id_properties_id = None - self.alias_name = alias_name self.rule_state = rule_state self.schema_name = schema_name self.table_name = table_name self.column_name = column_name + self.alias_name = alias_name self.masking_function = masking_function self.number_from = number_from self.number_to = number_to @@ -3902,23 +4034,31 @@ def __init__( class DataMaskingRuleListResult(_serialization.Model): - """The response to a list data masking rules request. + """The list of database data masking rules. + + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of database data masking rules. + :ivar value: Array of results. :vartype value: list[~azure.mgmt.sql.models.DataMaskingRule] + :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": "[DataMaskingRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.DataMaskingRule"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of database data masking rules. - :paramtype value: list[~azure.mgmt.sql.models.DataMaskingRule] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value + self.value = None + self.next_link = None class DataWarehouseUserActivities(ProxyResource): @@ -4073,90 +4213,276 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar target_database: The name of the target database. - :vartype target_database: str - :ivar source_endpoint: The source endpoint. - :vartype source_endpoint: str - :ivar primary_availability_group_name: The primary availability group name. - :vartype primary_availability_group_name: str - :ivar secondary_availability_group_name: The secondary availability group name. - :vartype secondary_availability_group_name: str - :ivar replication_mode: The replication mode of a distributed availability group. Parameter - will be ignored during link creation. Known values are: "Async", "Sync", and "Async". - :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationMode - :ivar distributed_availability_group_id: The distributed availability group id. + :ivar distributed_availability_group_name: Name of the distributed availability group. + :vartype distributed_availability_group_name: str + :ivar distributed_availability_group_id: ID of the distributed availability group. :vartype distributed_availability_group_id: str - :ivar source_replica_id: The source replica id. - :vartype source_replica_id: str - :ivar target_replica_id: The target replica id. - :vartype target_replica_id: str - :ivar link_state: The link state. - :vartype link_state: str - :ivar last_hardened_lsn: The last hardened lsn. - :vartype last_hardened_lsn: str + :ivar replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and + "Async". + :vartype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType + :ivar partner_link_role: SQL server side link role. Known values are: "Primary" and + "Secondary". + :vartype partner_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar partner_availability_group_name: SQL server side availability group name. + :vartype partner_availability_group_name: str + :ivar partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. + :vartype partner_endpoint: str + :ivar instance_link_role: Managed instance side link role. Known values are: "Primary" and + "Secondary". + :vartype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole + :ivar instance_availability_group_name: Managed instance side availability group name. + :vartype instance_availability_group_name: str + :ivar failover_mode: The link failover mode - can be Manual if intended to be used for two-way + failover with a supported SQL Server, or None for one-way failover to Azure. Known values are: + "None" and "Manual". + :vartype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType + :ivar seeding_mode: Database seeding mode – can be Automatic (default), or Manual for supported + scenarios. Known values are: "Automatic" and "Manual". + :vartype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType + :ivar databases: Databases in the distributed availability group. + :vartype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "distributed_availability_group_name": {"readonly": True}, "distributed_availability_group_id": {"readonly": True}, - "source_replica_id": {"readonly": True}, - "target_replica_id": {"readonly": True}, - "link_state": {"readonly": True}, - "last_hardened_lsn": {"readonly": True}, + "partner_link_role": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "target_database": {"key": "properties.targetDatabase", "type": "str"}, - "source_endpoint": {"key": "properties.sourceEndpoint", "type": "str"}, - "primary_availability_group_name": {"key": "properties.primaryAvailabilityGroupName", "type": "str"}, - "secondary_availability_group_name": {"key": "properties.secondaryAvailabilityGroupName", "type": "str"}, - "replication_mode": {"key": "properties.replicationMode", "type": "str"}, + "distributed_availability_group_name": {"key": "properties.distributedAvailabilityGroupName", "type": "str"}, "distributed_availability_group_id": {"key": "properties.distributedAvailabilityGroupId", "type": "str"}, - "source_replica_id": {"key": "properties.sourceReplicaId", "type": "str"}, - "target_replica_id": {"key": "properties.targetReplicaId", "type": "str"}, - "link_state": {"key": "properties.linkState", "type": "str"}, - "last_hardened_lsn": {"key": "properties.lastHardenedLsn", "type": "str"}, + "replication_mode": {"key": "properties.replicationMode", "type": "str"}, + "partner_link_role": {"key": "properties.partnerLinkRole", "type": "str"}, + "partner_availability_group_name": {"key": "properties.partnerAvailabilityGroupName", "type": "str"}, + "partner_endpoint": {"key": "properties.partnerEndpoint", "type": "str"}, + "instance_link_role": {"key": "properties.instanceLinkRole", "type": "str"}, + "instance_availability_group_name": {"key": "properties.instanceAvailabilityGroupName", "type": "str"}, + "failover_mode": {"key": "properties.failoverMode", "type": "str"}, + "seeding_mode": {"key": "properties.seedingMode", "type": "str"}, + "databases": {"key": "properties.databases", "type": "[DistributedAvailabilityGroupDatabase]"}, } def __init__( self, *, - target_database: Optional[str] = None, - source_endpoint: Optional[str] = None, - primary_availability_group_name: Optional[str] = None, - secondary_availability_group_name: Optional[str] = None, - replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = None, + partner_availability_group_name: Optional[str] = None, + partner_endpoint: Optional[str] = None, + instance_link_role: Optional[Union[str, "_models.LinkRole"]] = None, + instance_availability_group_name: Optional[str] = None, + failover_mode: Optional[Union[str, "_models.FailoverModeType"]] = None, + seeding_mode: Optional[Union[str, "_models.SeedingModeType"]] = None, + databases: Optional[List["_models.DistributedAvailabilityGroupDatabase"]] = None, **kwargs: Any ) -> None: """ - :keyword target_database: The name of the target database. - :paramtype target_database: str - :keyword source_endpoint: The source endpoint. - :paramtype source_endpoint: str - :keyword primary_availability_group_name: The primary availability group name. - :paramtype primary_availability_group_name: str - :keyword secondary_availability_group_name: The secondary availability group name. - :paramtype secondary_availability_group_name: str - :keyword replication_mode: The replication mode of a distributed availability group. Parameter - will be ignored during link creation. Known values are: "Async", "Sync", and "Async". - :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationMode - """ - super().__init__(**kwargs) - self.target_database = target_database - self.source_endpoint = source_endpoint - self.primary_availability_group_name = primary_availability_group_name - self.secondary_availability_group_name = secondary_availability_group_name - self.replication_mode = replication_mode + :keyword replication_mode: Replication mode of the link. Known values are: "Async", "Sync", and + "Async". + :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType + :keyword partner_availability_group_name: SQL server side availability group name. + :paramtype partner_availability_group_name: str + :keyword partner_endpoint: SQL server side endpoint - IP or DNS resolvable name. + :paramtype partner_endpoint: str + :keyword instance_link_role: Managed instance side link role. Known values are: "Primary" and + "Secondary". + :paramtype instance_link_role: str or ~azure.mgmt.sql.models.LinkRole + :keyword instance_availability_group_name: Managed instance side availability group name. + :paramtype instance_availability_group_name: str + :keyword failover_mode: The link failover mode - can be Manual if intended to be used for + two-way failover with a supported SQL Server, or None for one-way failover to Azure. Known + values are: "None" and "Manual". + :paramtype failover_mode: str or ~azure.mgmt.sql.models.FailoverModeType + :keyword seeding_mode: Database seeding mode – can be Automatic (default), or Manual for + supported scenarios. Known values are: "Automatic" and "Manual". + :paramtype seeding_mode: str or ~azure.mgmt.sql.models.SeedingModeType + :keyword databases: Databases in the distributed availability group. + :paramtype databases: list[~azure.mgmt.sql.models.DistributedAvailabilityGroupDatabase] + """ + super().__init__(**kwargs) + self.distributed_availability_group_name = None self.distributed_availability_group_id = None - self.source_replica_id = None - self.target_replica_id = None - self.link_state = None + self.replication_mode = replication_mode + self.partner_link_role = None + self.partner_availability_group_name = partner_availability_group_name + self.partner_endpoint = partner_endpoint + self.instance_link_role = instance_link_role + self.instance_availability_group_name = instance_availability_group_name + self.failover_mode = failover_mode + self.seeding_mode = seeding_mode + self.databases = databases + + +class DistributedAvailabilityGroupDatabase(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Database specific information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar database_name: The name of the database in link. + :vartype database_name: str + :ivar instance_replica_id: Managed instance replica id. + :vartype instance_replica_id: str + :ivar partner_replica_id: SQL server replica id. + :vartype partner_replica_id: str + :ivar replica_state: Current link state. + :vartype replica_state: str + :ivar synchronization_health: Link health state. Known values are: "NOT_HEALTHY", + "PARTIALLY_HEALTHY", and "HEALTHY". + :vartype synchronization_health: str or ~azure.mgmt.sql.models.ReplicaSynchronizationHealth + :ivar connected_state: Link connected state. Known values are: "DISCONNECTED" and "CONNECTED". + :vartype connected_state: str or ~azure.mgmt.sql.models.ReplicaConnectedState + :ivar last_received_lsn: Last received LSN. + :vartype last_received_lsn: str + :ivar last_received_time: Last received LSN time. + :vartype last_received_time: ~datetime.datetime + :ivar last_sent_lsn: Last sent LSN. + :vartype last_sent_lsn: str + :ivar last_sent_time: Last sent LSN time. + :vartype last_sent_time: ~datetime.datetime + :ivar last_commit_lsn: Last commit LSN. + :vartype last_commit_lsn: str + :ivar last_commit_time: Last commit LSN time. + :vartype last_commit_time: ~datetime.datetime + :ivar last_hardened_lsn: Last hardened LSN. + :vartype last_hardened_lsn: str + :ivar last_hardened_time: Last hardened LSN time. + :vartype last_hardened_time: ~datetime.datetime + :ivar last_backup_lsn: Last backup LSN. + :vartype last_backup_lsn: str + :ivar last_backup_time: Last backup LSN time. + :vartype last_backup_time: ~datetime.datetime + :ivar most_recent_link_error: The most recent link connection error description. + :vartype most_recent_link_error: str + :ivar partner_auth_cert_validity: SQL server certificate validity. + :vartype partner_auth_cert_validity: ~azure.mgmt.sql.models.CertificateInfo + :ivar instance_send_replication_lag_seconds: Replication lag when Managed Instance link side is + primary. + :vartype instance_send_replication_lag_seconds: int + :ivar instance_redo_replication_lag_seconds: Redo lag when Managed Instance link side is + primary. + :vartype instance_redo_replication_lag_seconds: int + """ + + _validation = { + "instance_replica_id": {"readonly": True}, + "partner_replica_id": {"readonly": True}, + "replica_state": {"readonly": True}, + "synchronization_health": {"readonly": True}, + "connected_state": {"readonly": True}, + "last_received_lsn": {"readonly": True}, + "last_received_time": {"readonly": True}, + "last_sent_lsn": {"readonly": True}, + "last_sent_time": {"readonly": True}, + "last_commit_lsn": {"readonly": True}, + "last_commit_time": {"readonly": True}, + "last_hardened_lsn": {"readonly": True}, + "last_hardened_time": {"readonly": True}, + "last_backup_lsn": {"readonly": True}, + "last_backup_time": {"readonly": True}, + "most_recent_link_error": {"readonly": True}, + "partner_auth_cert_validity": {"readonly": True}, + "instance_send_replication_lag_seconds": {"readonly": True}, + "instance_redo_replication_lag_seconds": {"readonly": True}, + } + + _attribute_map = { + "database_name": {"key": "databaseName", "type": "str"}, + "instance_replica_id": {"key": "instanceReplicaId", "type": "str"}, + "partner_replica_id": {"key": "partnerReplicaId", "type": "str"}, + "replica_state": {"key": "replicaState", "type": "str"}, + "synchronization_health": {"key": "synchronizationHealth", "type": "str"}, + "connected_state": {"key": "connectedState", "type": "str"}, + "last_received_lsn": {"key": "lastReceivedLsn", "type": "str"}, + "last_received_time": {"key": "lastReceivedTime", "type": "iso-8601"}, + "last_sent_lsn": {"key": "lastSentLsn", "type": "str"}, + "last_sent_time": {"key": "lastSentTime", "type": "iso-8601"}, + "last_commit_lsn": {"key": "lastCommitLsn", "type": "str"}, + "last_commit_time": {"key": "lastCommitTime", "type": "iso-8601"}, + "last_hardened_lsn": {"key": "lastHardenedLsn", "type": "str"}, + "last_hardened_time": {"key": "lastHardenedTime", "type": "iso-8601"}, + "last_backup_lsn": {"key": "lastBackupLsn", "type": "str"}, + "last_backup_time": {"key": "lastBackupTime", "type": "iso-8601"}, + "most_recent_link_error": {"key": "mostRecentLinkError", "type": "str"}, + "partner_auth_cert_validity": {"key": "partnerAuthCertValidity", "type": "CertificateInfo"}, + "instance_send_replication_lag_seconds": {"key": "instanceSendReplicationLagSeconds", "type": "int"}, + "instance_redo_replication_lag_seconds": {"key": "instanceRedoReplicationLagSeconds", "type": "int"}, + } + + def __init__(self, *, database_name: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword database_name: The name of the database in link. + :paramtype database_name: str + """ + super().__init__(**kwargs) + self.database_name = database_name + self.instance_replica_id = None + self.partner_replica_id = None + self.replica_state = None + self.synchronization_health = None + self.connected_state = None + self.last_received_lsn = None + self.last_received_time = None + self.last_sent_lsn = None + self.last_sent_time = None + self.last_commit_lsn = None + self.last_commit_time = None self.last_hardened_lsn = None + self.last_hardened_time = None + self.last_backup_lsn = None + self.last_backup_time = None + self.most_recent_link_error = None + self.partner_auth_cert_validity = None + self.instance_send_replication_lag_seconds = None + self.instance_redo_replication_lag_seconds = None + + +class DistributedAvailabilityGroupSetRole(_serialization.Model): + """Distributed availability group failover request. + + All required parameters must be populated in order to send to Azure. + + :ivar instance_role: New role of managed instance in a distributed availability group, can be + Primary or Secondary. Required. Known values are: "Primary" and "Secondary". + :vartype instance_role: str or ~azure.mgmt.sql.models.InstanceRole + :ivar role_change_type: The type of the role change, can be Planned or Forced. Required. Known + values are: "Forced" and "Planned". + :vartype role_change_type: str or ~azure.mgmt.sql.models.RoleChangeType + """ + + _validation = { + "instance_role": {"required": True}, + "role_change_type": {"required": True}, + } + + _attribute_map = { + "instance_role": {"key": "instanceRole", "type": "str"}, + "role_change_type": {"key": "roleChangeType", "type": "str"}, + } + + def __init__( + self, + *, + instance_role: Union[str, "_models.InstanceRole"], + role_change_type: Union[str, "_models.RoleChangeType"], + **kwargs: Any + ) -> None: + """ + :keyword instance_role: New role of managed instance in a distributed availability group, can + be Primary or Secondary. Required. Known values are: "Primary" and "Secondary". + :paramtype instance_role: str or ~azure.mgmt.sql.models.InstanceRole + :keyword role_change_type: The type of the role change, can be Planned or Forced. Required. + Known values are: "Forced" and "Planned". + :paramtype role_change_type: str or ~azure.mgmt.sql.models.RoleChangeType + """ + super().__init__(**kwargs) + self.instance_role = instance_role + self.role_change_type = role_change_type class DistributedAvailabilityGroupsListResult(_serialization.Model): @@ -4205,6 +4531,8 @@ class EditionCapability(_serialization.Model): :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_pinning: Whether or not zone pinning is supported for the edition. + :vartype zone_pinning: bool :ivar status: The status of the capability. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -4218,6 +4546,7 @@ class EditionCapability(_serialization.Model): "zone_redundant": {"readonly": True}, "read_scale": {"readonly": True}, "supported_storage_capabilities": {"readonly": True}, + "zone_pinning": {"readonly": True}, "status": {"readonly": True}, } @@ -4230,6 +4559,7 @@ class EditionCapability(_serialization.Model): "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, "read_scale": {"key": "readScale", "type": "ReadScaleCapability"}, "supported_storage_capabilities": {"key": "supportedStorageCapabilities", "type": "[StorageCapability]"}, + "zone_pinning": {"key": "zonePinning", "type": "bool"}, "status": {"key": "status", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } @@ -4245,6 +4575,7 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.zone_redundant = None self.read_scale = None self.supported_storage_capabilities = None + self.zone_pinning = None self.status = None self.reason = reason @@ -4303,6 +4634,9 @@ class ElasticPool(TrackedResource): # pylint: disable=too-many-instance-attribu elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic pools. :vartype high_availability_replica_count: int + :ivar auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: "Default" and "VBS". :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType @@ -4338,6 +4672,7 @@ class ElasticPool(TrackedResource): # pylint: disable=too-many-instance-attribu "license_type": {"key": "properties.licenseType", "type": "str"}, "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, + "auto_pause_delay": {"key": "properties.autoPauseDelay", "type": "int"}, "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, } @@ -4355,6 +4690,7 @@ def __init__( license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, maintenance_configuration_id: Optional[str] = None, high_availability_replica_count: Optional[int] = None, + auto_pause_delay: Optional[int] = None, preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, **kwargs: Any @@ -4395,6 +4731,9 @@ def __init__( elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic pools. :paramtype high_availability_replica_count: int + :keyword auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :paramtype auto_pause_delay: int :keyword preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: "Default" and "VBS". :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType @@ -4414,367 +4753,69 @@ def __init__( self.license_type = license_type self.maintenance_configuration_id = maintenance_configuration_id self.high_availability_replica_count = high_availability_replica_count + self.auto_pause_delay = auto_pause_delay self.preferred_enclave_type = preferred_enclave_type self.availability_zone = availability_zone -class ElasticPoolActivity(ProxyResource): # pylint: disable=too-many-instance-attributes - """Represents the activity on an elastic pool. +class ElasticPoolEditionCapability(_serialization.Model): + """The elastic pool edition capability. 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. + :ivar name: The elastic pool edition name. :vartype name: str - :ivar type: Resource type. - :vartype type: 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. - :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: int - :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 + :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 zone_pinning: Whether or not zone pinning is supported for the edition. + :vartype zone_pinning: bool + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _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}, + "supported_elastic_pool_performance_levels": {"readonly": True}, + "zone_redundant": {"readonly": True}, + "zone_pinning": {"readonly": True}, + "status": {"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": "int"}, - "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"}, + "supported_elastic_pool_performance_levels": { + "key": "supportedElasticPoolPerformanceLevels", + "type": "[ElasticPoolPerformanceLevelCapability]", + }, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, + "zone_pinning": {"key": "zonePinning", "type": "bool"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=too-many-locals + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword location: The geo-location where the resource lives. - :paramtype location: str + :keyword reason: The reason for the capability not being available. + :paramtype reason: str """ super().__init__(**kwargs) - self.location = location - 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 + self.name = None + self.supported_elastic_pool_performance_levels = None + self.zone_redundant = None + self.zone_pinning = None + self.status = None + self.reason = reason -class ElasticPoolActivityListResult(_serialization.Model): - """Represents the response to a list elastic pool activity request. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The list of elastic pool activities. Required. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolActivity]"}, - } - - def __init__(self, *, value: List["_models.ElasticPoolActivity"], **kwargs: Any) -> None: - """ - :keyword value: The list of elastic pool activities. Required. - :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] - """ - super().__init__(**kwargs) - self.value = value - - -class ElasticPoolDatabaseActivity(ProxyResource): # pylint: disable=too-many-instance-attributes - """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 - :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). - :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, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: The geo-location where the resource lives. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - 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(_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. - - :ivar value: The list of elastic pool database activities. Required. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolDatabaseActivity]"}, - } - - def __init__(self, *, value: List["_models.ElasticPoolDatabaseActivity"], **kwargs: Any) -> None: - """ - :keyword value: The list of elastic pool database activities. Required. - :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - """ - super().__init__(**kwargs) - self.value = value - - -class ElasticPoolEditionCapability(_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. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype 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, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.name = None - self.supported_elastic_pool_performance_levels = None - self.zone_redundant = None - self.status = None - self.reason = reason - - -class ElasticPoolListResult(_serialization.Model): - """The result of an elastic pool list request. +class ElasticPoolListResult(_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. @@ -5028,25 +5069,36 @@ class ElasticPoolPerDatabaseSettings(_serialization.Model): :vartype min_capacity: float :ivar max_capacity: The maximum capacity any one database can consume. :vartype max_capacity: float + :ivar auto_pause_delay: Auto Pause Delay for per database within pool. + :vartype auto_pause_delay: int """ _attribute_map = { "min_capacity": {"key": "minCapacity", "type": "float"}, "max_capacity": {"key": "maxCapacity", "type": "float"}, + "auto_pause_delay": {"key": "autoPauseDelay", "type": "int"}, } def __init__( - self, *, min_capacity: Optional[float] = None, max_capacity: Optional[float] = None, **kwargs: Any + self, + *, + min_capacity: Optional[float] = None, + max_capacity: Optional[float] = None, + auto_pause_delay: Optional[int] = None, + **kwargs: Any ) -> None: """ :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 + :keyword auto_pause_delay: Auto Pause Delay for per database within pool. + :paramtype auto_pause_delay: int """ super().__init__(**kwargs) self.min_capacity = min_capacity self.max_capacity = max_capacity + self.auto_pause_delay = auto_pause_delay class ElasticPoolPerformanceLevelCapability(_serialization.Model): # pylint: disable=too-many-instance-attributes @@ -5077,6 +5129,14 @@ class ElasticPoolPerformanceLevelCapability(_serialization.Model): # pylint: di :ivar supported_maintenance_configurations: List of supported maintenance configurations. :vartype supported_maintenance_configurations: list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] + :ivar supported_min_capacities: List of supported min capacities. + :vartype supported_min_capacities: list[~azure.mgmt.sql.models.MinCapacityCapability] + :ivar supported_auto_pause_delay: Supported time range for auto pause delay. + :vartype supported_auto_pause_delay: ~azure.mgmt.sql.models.AutoPauseDelayTimeRange + :ivar supported_per_database_auto_pause_delay: Supported time range for per database auto pause + delay. + :vartype supported_per_database_auto_pause_delay: + ~azure.mgmt.sql.models.PerDatabaseAutoPauseDelayTimeRange :ivar status: The status of the capability. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -5095,6 +5155,9 @@ class ElasticPoolPerformanceLevelCapability(_serialization.Model): # pylint: di "supported_per_database_max_performance_levels": {"readonly": True}, "zone_redundant": {"readonly": True}, "supported_maintenance_configurations": {"readonly": True}, + "supported_min_capacities": {"readonly": True}, + "supported_auto_pause_delay": {"readonly": True}, + "supported_per_database_auto_pause_delay": {"readonly": True}, "status": {"readonly": True}, } @@ -5115,6 +5178,12 @@ class ElasticPoolPerformanceLevelCapability(_serialization.Model): # pylint: di "key": "supportedMaintenanceConfigurations", "type": "[MaintenanceConfigurationCapability]", }, + "supported_min_capacities": {"key": "supportedMinCapacities", "type": "[MinCapacityCapability]"}, + "supported_auto_pause_delay": {"key": "supportedAutoPauseDelay", "type": "AutoPauseDelayTimeRange"}, + "supported_per_database_auto_pause_delay": { + "key": "supportedPerDatabaseAutoPauseDelay", + "type": "PerDatabaseAutoPauseDelayTimeRange", + }, "status": {"key": "status", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } @@ -5135,6 +5204,9 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.supported_per_database_max_performance_levels = None self.zone_redundant = None self.supported_maintenance_configurations = None + self.supported_min_capacities = None + self.supported_auto_pause_delay = None + self.supported_per_database_auto_pause_delay = None self.status = None self.reason = reason @@ -5165,6 +5237,9 @@ class ElasticPoolUpdate(_serialization.Model): # pylint: disable=too-many-insta elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic pools. :vartype high_availability_replica_count: int + :ivar auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :vartype auto_pause_delay: int :ivar preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: "Default" and "VBS". :vartype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType @@ -5183,6 +5258,7 @@ class ElasticPoolUpdate(_serialization.Model): # pylint: disable=too-many-insta "license_type": {"key": "properties.licenseType", "type": "str"}, "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, "high_availability_replica_count": {"key": "properties.highAvailabilityReplicaCount", "type": "int"}, + "auto_pause_delay": {"key": "properties.autoPauseDelay", "type": "int"}, "preferred_enclave_type": {"key": "properties.preferredEnclaveType", "type": "str"}, "availability_zone": {"key": "properties.availabilityZone", "type": "str"}, } @@ -5199,6 +5275,7 @@ def __init__( license_type: Optional[Union[str, "_models.ElasticPoolLicenseType"]] = None, maintenance_configuration_id: Optional[str] = None, high_availability_replica_count: Optional[int] = None, + auto_pause_delay: Optional[int] = None, preferred_enclave_type: Optional[Union[str, "_models.AlwaysEncryptedEnclaveType"]] = None, availability_zone: Optional[Union[str, "_models.AvailabilityZoneType"]] = None, **kwargs: Any @@ -5228,6 +5305,9 @@ def __init__( elastic pool that are used to provide high availability. Applicable only to Hyperscale elastic pools. :paramtype high_availability_replica_count: int + :keyword auto_pause_delay: Time in minutes after which elastic pool is automatically paused. A + value of -1 means that automatic pause is disabled. + :paramtype auto_pause_delay: int :keyword preferred_enclave_type: Type of enclave requested on the elastic pool. Known values are: "Default" and "VBS". :paramtype preferred_enclave_type: str or ~azure.mgmt.sql.models.AlwaysEncryptedEnclaveType @@ -5245,6 +5325,7 @@ def __init__( self.license_type = license_type self.maintenance_configuration_id = maintenance_configuration_id self.high_availability_replica_count = high_availability_replica_count + self.auto_pause_delay = auto_pause_delay self.preferred_enclave_type = preferred_enclave_type self.availability_zone = availability_zone @@ -5479,6 +5560,98 @@ def __init__(self, **kwargs: Any) -> None: self.port = None +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + 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 + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.sql.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.sql.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.sql.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.sql.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class ExportDatabaseDefinition(_serialization.Model): """Contains the information necessary to perform export database operation. @@ -6416,22 +6589,32 @@ class FailoverGroupReadOnlyEndpoint(_serialization.Model): :ivar failover_policy: Failover policy of the read-only endpoint for the failover group. Known values are: "Disabled" and "Enabled". :vartype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + :ivar target_server: The target partner server where the read-only endpoint points to. + :vartype target_server: str """ _attribute_map = { "failover_policy": {"key": "failoverPolicy", "type": "str"}, + "target_server": {"key": "targetServer", "type": "str"}, } def __init__( - self, *, failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = None, **kwargs: Any + self, + *, + failover_policy: Optional[Union[str, "_models.ReadOnlyEndpointFailoverPolicy"]] = None, + target_server: Optional[str] = None, + **kwargs: Any ) -> None: """ :keyword failover_policy: Failover policy of the read-only endpoint for the failover group. Known values are: "Disabled" and "Enabled". :paramtype failover_policy: str or ~azure.mgmt.sql.models.ReadOnlyEndpointFailoverPolicy + :keyword target_server: The target partner server where the read-only endpoint points to. + :paramtype target_server: str """ super().__init__(**kwargs) self.failover_policy = failover_policy + self.target_server = target_server class FailoverGroupReadWriteEndpoint(_serialization.Model): @@ -6494,6 +6677,8 @@ class FailoverGroupUpdate(_serialization.Model): :vartype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint :ivar databases: List of databases in the failover group. :vartype databases: list[str] + :ivar partner_servers: List of partner server information for the failover group. + :vartype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] """ _attribute_map = { @@ -6501,6 +6686,7 @@ class FailoverGroupUpdate(_serialization.Model): "read_write_endpoint": {"key": "properties.readWriteEndpoint", "type": "FailoverGroupReadWriteEndpoint"}, "read_only_endpoint": {"key": "properties.readOnlyEndpoint", "type": "FailoverGroupReadOnlyEndpoint"}, "databases": {"key": "properties.databases", "type": "[str]"}, + "partner_servers": {"key": "properties.partnerServers", "type": "[PartnerInfo]"}, } def __init__( @@ -6510,6 +6696,7 @@ def __init__( read_write_endpoint: Optional["_models.FailoverGroupReadWriteEndpoint"] = None, read_only_endpoint: Optional["_models.FailoverGroupReadOnlyEndpoint"] = None, databases: Optional[List[str]] = None, + partner_servers: Optional[List["_models.PartnerInfo"]] = None, **kwargs: Any ) -> None: """ @@ -6521,12 +6708,15 @@ def __init__( :paramtype read_only_endpoint: ~azure.mgmt.sql.models.FailoverGroupReadOnlyEndpoint :keyword databases: List of databases in the failover group. :paramtype databases: list[str] + :keyword partner_servers: List of partner server information for the failover group. + :paramtype partner_servers: list[~azure.mgmt.sql.models.PartnerInfo] """ super().__init__(**kwargs) self.tags = tags self.read_write_endpoint = read_write_endpoint self.read_only_endpoint = read_only_endpoint self.databases = databases + self.partner_servers = partner_servers class ResourceWithWritableName(_serialization.Model): @@ -6701,12 +6891,40 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class GeoBackupPolicy(ProxyResource): - """A database geo backup policy. +class FreeLimitExhaustionBehaviorCapability(_serialization.Model): + """Supported free limit exhaustion behavior options. 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 exhaustion_behavior_type: Free limit exhaustion behavior type. Known values are: + "AutoPause" and "BillOverUsage". + :vartype exhaustion_behavior_type: str or ~azure.mgmt.sql.models.FreeLimitExhaustionBehavior + :ivar status: Free limit exhaustion behavior status. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + """ + + _validation = { + "exhaustion_behavior_type": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "exhaustion_behavior_type": {"key": "exhaustionBehaviorType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.exhaustion_behavior_type = None + self.status = None + + +class GeoBackupPolicy(ProxyResource): + """A Geo backup policy. + + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6714,12 +6932,11 @@ class GeoBackupPolicy(ProxyResource): :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 - :ivar state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". + :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. + :vartype kind: str + :ivar state: The state of the geo backup policy. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState :ivar storage_type: The storage type of the geo backup policy. :vartype storage_type: str @@ -6729,9 +6946,8 @@ class GeoBackupPolicy(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "kind": {"readonly": True}, "location": {"readonly": True}, - "state": {"required": True}, + "kind": {"readonly": True}, "storage_type": {"readonly": True}, } @@ -6739,43 +6955,50 @@ class GeoBackupPolicy(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, "state": {"key": "properties.state", "type": "str"}, "storage_type": {"key": "properties.storageType", "type": "str"}, } - def __init__(self, *, state: Union[str, "_models.GeoBackupPolicyState"], **kwargs: Any) -> None: + def __init__(self, *, state: Optional[Union[str, "_models.GeoBackupPolicyState"]] = None, **kwargs: Any) -> None: """ - :keyword state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". + :keyword state: The state of the geo backup policy. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState """ super().__init__(**kwargs) - self.kind = None self.location = None + self.kind = None self.state = state self.storage_type = None class GeoBackupPolicyListResult(_serialization.Model): - """The response to a list geo backup policies request. + """The list of geo backup policies. - :ivar value: The list of geo backup 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.GeoBackupPolicy] + :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": "[GeoBackupPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.GeoBackupPolicy"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of geo backup policies. - :paramtype value: list[~azure.mgmt.sql.models.GeoBackupPolicy] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value + self.value = None + self.next_link = None class ImportExistingDatabaseDefinition(_serialization.Model): @@ -6886,7 +7109,7 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ImportExportExtensionsOperationResult(ProxyResource): +class ImportExportExtensionsOperationResult(ProxyResource): # pylint: disable=too-many-instance-attributes """An Extension operation result resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -6911,6 +7134,14 @@ class ImportExportExtensionsOperationResult(ProxyResource): :vartype status: str :ivar error_message: Error message. :vartype error_message: str + :ivar queued_time: Queued time. + :vartype queued_time: str + :ivar blob_uri: Blob URI. + :vartype blob_uri: 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 = { @@ -6924,6 +7155,9 @@ class ImportExportExtensionsOperationResult(ProxyResource): "database_name": {"readonly": True}, "status": {"readonly": True}, "error_message": {"readonly": True}, + "queued_time": {"readonly": True}, + "blob_uri": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { @@ -6937,6 +7171,12 @@ class ImportExportExtensionsOperationResult(ProxyResource): "database_name": {"key": "properties.databaseName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "error_message": {"key": "properties.errorMessage", "type": "str"}, + "queued_time": {"key": "properties.queuedTime", "type": "str"}, + "blob_uri": {"key": "properties.blobUri", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnectionRequestStatus]", + }, } def __init__(self, **kwargs: Any) -> None: @@ -6949,6 +7189,9 @@ def __init__(self, **kwargs: Any) -> None: self.database_name = None self.status = None self.error_message = None + self.queued_time = None + self.blob_uri = None + self.private_endpoint_connections = None class ImportExportOperationResult(ProxyResource): # pylint: disable=too-many-instance-attributes @@ -7063,7 +7306,7 @@ class ImportNewDatabaseDefinition(_serialization.Model): # pylint: disable=too- :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.NetworkIsolationSettingsAutoGenerated + :vartype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ _validation = { @@ -7085,7 +7328,7 @@ class ImportNewDatabaseDefinition(_serialization.Model): # pylint: disable=too- "administrator_login": {"key": "administratorLogin", "type": "str"}, "administrator_login_password": {"key": "administratorLoginPassword", "type": "str"}, "authentication_type": {"key": "authenticationType", "type": "str"}, - "network_isolation": {"key": "networkIsolation", "type": "NetworkIsolationSettingsAutoGenerated"}, + "network_isolation": {"key": "networkIsolation", "type": "NetworkIsolationSettings"}, } def __init__( @@ -7101,7 +7344,7 @@ def __init__( service_objective_name: Optional[str] = None, max_size_bytes: Optional[str] = None, authentication_type: Optional[str] = None, - network_isolation: Optional["_models.NetworkIsolationSettingsAutoGenerated"] = None, + network_isolation: Optional["_models.NetworkIsolationSettings"] = None, **kwargs: Any ) -> None: """ @@ -7128,7 +7371,7 @@ def __init__( :paramtype authentication_type: str :keyword network_isolation: Optional resource information to enable network isolation for request. - :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettingsAutoGenerated + :paramtype network_isolation: ~azure.mgmt.sql.models.NetworkIsolationSettings """ super().__init__(**kwargs) self.database_name = database_name @@ -7331,7 +7574,7 @@ def __init__( self.failover_with_data_loss_grace_period_minutes = failover_with_data_loss_grace_period_minutes -class InstancePool(TrackedResource): +class InstancePool(TrackedResource): # pylint: disable=too-many-instance-attributes """An Azure SQL instance pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -7358,6 +7601,11 @@ class InstancePool(TrackedResource): license is included) and 'BasePrice' (without SQL license price). Known values are: "LicenseIncluded" and "BasePrice". :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :ivar dns_zone: The Dns Zone that the managed instance pool is in. + :vartype dns_zone: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :vartype maintenance_configuration_id: str """ _validation = { @@ -7365,6 +7613,7 @@ class InstancePool(TrackedResource): "name": {"readonly": True}, "type": {"readonly": True}, "location": {"required": True}, + "dns_zone": {"readonly": True}, } _attribute_map = { @@ -7377,6 +7626,8 @@ class InstancePool(TrackedResource): "subnet_id": {"key": "properties.subnetId", "type": "str"}, "v_cores": {"key": "properties.vCores", "type": "int"}, "license_type": {"key": "properties.licenseType", "type": "str"}, + "dns_zone": {"key": "properties.dnsZone", "type": "str"}, + "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, } def __init__( @@ -7388,6 +7639,7 @@ def __init__( subnet_id: Optional[str] = None, v_cores: Optional[int] = None, license_type: Optional[Union[str, "_models.InstancePoolLicenseType"]] = None, + maintenance_configuration_id: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -7405,12 +7657,17 @@ def __init__( license is included) and 'BasePrice' (without SQL license price). Known values are: "LicenseIncluded" and "BasePrice". :paramtype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :paramtype maintenance_configuration_id: str """ super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.subnet_id = subnet_id self.v_cores = v_cores self.license_type = license_type + self.dns_zone = None + self.maintenance_configuration_id = maintenance_configuration_id class InstancePoolEditionCapability(_serialization.Model): @@ -7531,21 +7788,77 @@ def __init__(self, **kwargs: Any) -> None: class InstancePoolUpdate(_serialization.Model): """An update to an Instance pool. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku: The name and tier of the SKU. + :vartype sku: ~azure.mgmt.sql.models.Sku :ivar tags: Resource tags. :vartype tags: dict[str, str] + :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). Known values are: + "LicenseIncluded" and "BasePrice". + :vartype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :ivar dns_zone: The Dns Zone that the managed instance pool is in. + :vartype dns_zone: str + :ivar maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :vartype maintenance_configuration_id: str """ + _validation = { + "dns_zone": {"readonly": True}, + } + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, "tags": {"key": "tags", "type": "{str}"}, + "subnet_id": {"key": "properties.subnetId", "type": "str"}, + "v_cores": {"key": "properties.vCores", "type": "int"}, + "license_type": {"key": "properties.licenseType", "type": "str"}, + "dns_zone": {"key": "properties.dnsZone", "type": "str"}, + "maintenance_configuration_id": {"key": "properties.maintenanceConfigurationId", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + subnet_id: Optional[str] = None, + v_cores: Optional[int] = None, + license_type: Optional[Union[str, "_models.InstancePoolLicenseType"]] = None, + maintenance_configuration_id: Optional[str] = None, + **kwargs: Any + ) -> None: """ + :keyword sku: The name and tier of the SKU. + :paramtype sku: ~azure.mgmt.sql.models.Sku :keyword tags: Resource tags. :paramtype tags: dict[str, str] + :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). Known values are: + "LicenseIncluded" and "BasePrice". + :paramtype license_type: str or ~azure.mgmt.sql.models.InstancePoolLicenseType + :keyword maintenance_configuration_id: Specifies maintenance configuration id to apply to this + managed instance. + :paramtype maintenance_configuration_id: str """ super().__init__(**kwargs) + self.sku = sku self.tags = tags + self.subnet_id = subnet_id + self.v_cores = v_cores + self.license_type = license_type + self.dns_zone = None + self.maintenance_configuration_id = maintenance_configuration_id class InstancePoolVcoresCapability(_serialization.Model): @@ -7608,7 +7921,7 @@ class IPv6FirewallRule(ProxyResourceWithWritableName): :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 startIpv6Address. + greater than or equal to startIpAddress. :vartype end_i_pv6_address: str """ @@ -7639,7 +7952,7 @@ def __init__( :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 startIpv6Address. + be greater than or equal to startIpAddress. :paramtype end_i_pv6_address: str """ super().__init__(name=name, **kwargs) @@ -7744,6 +8057,8 @@ class JobAgent(TrackedResource): :vartype tags: dict[str, str] :ivar sku: The name and tier of the SKU. :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar identity: The identity of the job agent. + :vartype identity: ~azure.mgmt.sql.models.JobAgentIdentity :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. Known values are: "Creating", "Ready", "Updating", @@ -7766,6 +8081,7 @@ class JobAgent(TrackedResource): "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "JobAgentIdentity"}, "database_id": {"key": "properties.databaseId", "type": "str"}, "state": {"key": "properties.state", "type": "str"}, } @@ -7776,6 +8092,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, + identity: Optional["_models.JobAgentIdentity"] = None, database_id: Optional[str] = None, **kwargs: Any ) -> None: @@ -7786,113 +8103,120 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The name and tier of the SKU. :paramtype sku: ~azure.mgmt.sql.models.Sku + :keyword identity: The identity of the job agent. + :paramtype identity: ~azure.mgmt.sql.models.JobAgentIdentity :keyword database_id: Resource ID of the database to store job metadata in. :paramtype database_id: str """ super().__init__(location=location, tags=tags, **kwargs) self.sku = sku + self.identity = identity self.database_id = database_id self.state = None -class JobAgentListResult(_serialization.Model): - """A list of Azure SQL job agents. +class JobAgentEditionCapability(_serialization.Model): + """The job agent edition capability. 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 + :ivar name: The job agent edition name. + :vartype name: str + :ivar supported_service_level_objectives: The list of supported service level objectives for + the edition. + :vartype supported_service_level_objectives: + list[~azure.mgmt.sql.models.JobAgentServiceLevelObjectiveCapability] + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[JobAgent]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "name": {"readonly": True}, + "supported_service_level_objectives": {"readonly": True}, + "status": {"readonly": True}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class JobAgentUpdate(_serialization.Model): - """An update to an Azure SQL job agent. - - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, + "name": {"key": "name", "type": "str"}, + "supported_service_level_objectives": { + "key": "supportedServiceLevelObjectives", + "type": "[JobAgentServiceLevelObjectiveCapability]", + }, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] + :keyword reason: The reason for the capability not being available. + :paramtype reason: str """ super().__init__(**kwargs) - self.tags = tags + self.name = None + self.supported_service_level_objectives = None + self.status = None + self.reason = reason -class JobCredential(ProxyResource): - """A stored credential that can be used by a job to connect to target databases. +class JobAgentIdentity(_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. + 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 username: The credential user name. - :vartype username: str - :ivar password: The credential password. - :vartype password: str + :ivar tenant_id: The job agent identity tenant id. + :vartype tenant_id: str + :ivar type: The job agent identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssignedUserAssigned". + :vartype type: str or ~azure.mgmt.sql.models.JobAgentIdentityType + :ivar user_assigned_identities: The resource ids of the user assigned identities to use. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.sql.models.JobAgentUserAssignedIdentity] """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, "type": {"key": "type", "type": "str"}, - "username": {"key": "properties.username", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{JobAgentUserAssignedIdentity}"}, } - def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + type: Union[str, "_models.JobAgentIdentityType"], + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[Dict[str, "_models.JobAgentUserAssignedIdentity"]] = None, + **kwargs: Any + ) -> None: """ - :keyword username: The credential user name. - :paramtype username: str - :keyword password: The credential password. - :paramtype password: str + :keyword tenant_id: The job agent identity tenant id. + :paramtype tenant_id: str + :keyword type: The job agent identity type. Required. Known values are: "None", + "SystemAssigned", "UserAssigned", and "SystemAssignedUserAssigned". + :paramtype type: str or ~azure.mgmt.sql.models.JobAgentIdentityType + :keyword user_assigned_identities: The resource ids of the user assigned identities to use. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.sql.models.JobAgentUserAssignedIdentity] """ super().__init__(**kwargs) - self.username = username - self.password = password + self.tenant_id = tenant_id + self.type = type + self.user_assigned_identities = user_assigned_identities -class JobCredentialListResult(_serialization.Model): - """A list of job credentials. +class JobAgentListResult(_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.JobCredential] + :vartype value: list[~azure.mgmt.sql.models.JobAgent] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ @@ -7903,7 +8227,7 @@ class JobCredentialListResult(_serialization.Model): } _attribute_map = { - "value": {"key": "value", "type": "[JobCredential]"}, + "value": {"key": "value", "type": "[JobAgent]"}, "next_link": {"key": "nextLink", "type": "str"}, } @@ -7914,12 +8238,225 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class JobExecution(ProxyResource): # pylint: disable=too-many-instance-attributes - """An execution of a job. +class JobAgentServiceLevelObjectiveCapability(_serialization.Model): + """The job agent service level objective capability. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. + :ivar name: The service objective name. + :vartype name: str + :ivar sku: The sku. + :vartype sku: ~azure.mgmt.sql.models.Sku + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + _validation = { + "name": {"readonly": True}, + "sku": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ + super().__init__(**kwargs) + self.name = None + self.sku = None + self.status = None + self.reason = reason + + +class JobAgentUpdate(_serialization.Model): + """An update to an Azure SQL job agent. + + :ivar identity: Managed identity assigned to job agent. + :vartype identity: ~azure.mgmt.sql.models.JobAgentIdentity + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "identity": {"key": "identity", "type": "JobAgentIdentity"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__( + self, + *, + identity: Optional["_models.JobAgentIdentity"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: Managed identity assigned to job agent. + :paramtype identity: ~azure.mgmt.sql.models.JobAgentIdentity + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + + +class JobAgentUserAssignedIdentity(_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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class JobAgentVersionCapability(_serialization.Model): + """The job agent version capability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The job agent version name. + :vartype name: str + :ivar supported_editions: The list of supported editions. + :vartype supported_editions: list[~azure.mgmt.sql.models.JobAgentEditionCapability] + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + _validation = { + "name": {"readonly": True}, + "supported_editions": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "supported_editions": {"key": "supportedEditions", "type": "[JobAgentEditionCapability]"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ + super().__init__(**kwargs) + self.name = None + self.supported_editions = None + self.status = None + self.reason = reason + + +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 + :ivar username: The credential user name. + :vartype username: str + :ivar password: The credential password. + :vartype 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, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword username: The credential user name. + :paramtype username: str + :keyword password: The credential password. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class JobCredentialListResult(_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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class JobExecution(ProxyResource): # pylint: disable=too-many-instance-attributes + """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 @@ -8104,6 +8641,78 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None +class JobPrivateEndpoint(ProxyResource): + """A job agent private endpoint. + + 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 target_server_azure_resource_id: ARM resource id of the server the private endpoint will + target. + :vartype target_server_azure_resource_id: str + :ivar private_endpoint_id: Private endpoint id of the private endpoint. + :vartype private_endpoint_id: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "private_endpoint_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "target_server_azure_resource_id": {"key": "properties.targetServerAzureResourceId", "type": "str"}, + "private_endpoint_id": {"key": "properties.privateEndpointId", "type": "str"}, + } + + def __init__(self, *, target_server_azure_resource_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword target_server_azure_resource_id: ARM resource id of the server the private endpoint + will target. + :paramtype target_server_azure_resource_id: str + """ + super().__init__(**kwargs) + self.target_server_azure_resource_id = target_server_azure_resource_id + self.private_endpoint_id = None + + +class JobPrivateEndpointListResult(_serialization.Model): + """A list of job agent private endpoints. + + 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.JobPrivateEndpoint] + :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": "[JobPrivateEndpoint]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + class JobSchedule(_serialization.Model): """Scheduling properties of a job. @@ -8131,8 +8740,8 @@ class JobSchedule(_serialization.Model): def __init__( self, *, - start_time: datetime.datetime = "0001-01-01T00:00:00+00:00", - end_time: datetime.datetime = "9999-12-31T11:59:59+00:00", + start_time: datetime.datetime = "0001-01-01T16:00:00-08:00", + end_time: datetime.datetime = "9999-12-31T03:59:59-08:00", type: Union[str, "_models.JobScheduleType"] = "Once", enabled: Optional[bool] = None, interval: Optional[str] = None, @@ -8395,7 +9004,7 @@ class JobStepOutput(_serialization.Model): :ivar table_name: The output destination table. Required. :vartype table_name: str :ivar credential: The resource ID of the credential to use to connect to the output - destination. Required. + destination. :vartype credential: str """ @@ -8403,7 +9012,6 @@ class JobStepOutput(_serialization.Model): "server_name": {"required": True}, "database_name": {"required": True}, "table_name": {"required": True}, - "credential": {"required": True}, } _attribute_map = { @@ -8423,11 +9031,11 @@ def __init__( server_name: str, database_name: str, table_name: str, - credential: str, type: Union[str, "_models.JobStepOutputType"] = "SqlDatabase", subscription_id: Optional[str] = None, resource_group_name: Optional[str] = None, schema_name: str = "dbo", + credential: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -8446,7 +9054,7 @@ def __init__( :keyword table_name: The output destination table. Required. :paramtype table_name: str :keyword credential: The resource ID of the credential to use to connect to the output - destination. Required. + destination. :paramtype credential: str """ super().__init__(**kwargs) @@ -8784,6 +9392,8 @@ class LocationCapabilities(_serialization.Model): :ivar supported_managed_instance_versions: The list of supported managed instance versions. :vartype supported_managed_instance_versions: list[~azure.mgmt.sql.models.ManagedInstanceVersionCapability] + :ivar supported_job_agent_versions: The list of supported job agent versions. + :vartype supported_job_agent_versions: list[~azure.mgmt.sql.models.JobAgentVersionCapability] :ivar status: The status of the capability. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -8795,6 +9405,7 @@ class LocationCapabilities(_serialization.Model): "name": {"readonly": True}, "supported_server_versions": {"readonly": True}, "supported_managed_instance_versions": {"readonly": True}, + "supported_job_agent_versions": {"readonly": True}, "status": {"readonly": True}, } @@ -8805,6 +9416,7 @@ class LocationCapabilities(_serialization.Model): "key": "supportedManagedInstanceVersions", "type": "[ManagedInstanceVersionCapability]", }, + "supported_job_agent_versions": {"key": "supportedJobAgentVersions", "type": "[JobAgentVersionCapability]"}, "status": {"key": "status", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } @@ -8818,6 +9430,7 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.name = None self.supported_server_versions = None self.supported_managed_instance_versions = None + self.supported_job_agent_versions = None self.status = None self.reason = reason @@ -9006,6 +9619,11 @@ class LongTermRetentionBackup(ProxyResource): # pylint: disable=too-many-instan values are: "Geo", "Local", "Zone", and "GeoZone". :vartype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar is_backup_immutable: The setting whether the LTR backup is immutable. + :vartype is_backup_immutable: bool + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backup. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier """ _validation = { @@ -9019,6 +9637,7 @@ class LongTermRetentionBackup(ProxyResource): # pylint: disable=too-many-instan "backup_time": {"readonly": True}, "backup_expiration_time": {"readonly": True}, "backup_storage_redundancy": {"readonly": True}, + "backup_storage_access_tier": {"readonly": True}, } _attribute_map = { @@ -9033,12 +9652,15 @@ class LongTermRetentionBackup(ProxyResource): # pylint: disable=too-many-instan "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"}, + "is_backup_immutable": {"key": "properties.isBackupImmutable", "type": "bool"}, + "backup_storage_access_tier": {"key": "properties.backupStorageAccessTier", "type": "str"}, } def __init__( self, *, requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + is_backup_immutable: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -9046,6 +9668,8 @@ def __init__( values are: "Geo", "Local", "Zone", and "GeoZone". :paramtype requested_backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :keyword is_backup_immutable: The setting whether the LTR backup is immutable. + :paramtype is_backup_immutable: bool """ super().__init__(**kwargs) self.server_name = None @@ -9056,6 +9680,8 @@ def __init__( self.backup_expiration_time = None self.backup_storage_redundancy = None self.requested_backup_storage_redundancy = requested_backup_storage_redundancy + self.is_backup_immutable = is_backup_immutable + self.backup_storage_access_tier = None class LongTermRetentionBackupListResult(_serialization.Model): @@ -10723,11 +11349,9 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att :ivar sku: Managed instance SKU. Allowed values for sku.name: GP_Gen5, GP_G8IM, GP_G8IH, BC_Gen5, BC_G8IM, BC_G8IH. :vartype sku: ~azure.mgmt.sql.models.Sku - :ivar provisioning_state: Known values are: "Creating", "Deleting", "Updating", "Unknown", - "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", "Canceled", - "NotSpecified", "Registering", and "TimedOut". - :vartype provisioning_state: str or - ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState + :ivar provisioning_state: Provisioning state of managed instance. Known values are: "Created", + "InProgress", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState :ivar managed_instance_create_mode: Specifies the mode of database creation. Default: Regular instance creation. @@ -10738,6 +11362,8 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att :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 + :ivar is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose edition. + :vartype is_general_purpose_v2: bool :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). :vartype administrator_login: str @@ -10752,12 +11378,29 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Known values are: "LicenseIncluded" and "BasePrice". :vartype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :ivar hybrid_secondary_usage: Hybrid secondary usage. Possible values are 'Active' (default + value) and 'Passive' (customer uses the secondary as Passive DR). Known values are: "Active" + and "Passive". + :vartype hybrid_secondary_usage: str or ~azure.mgmt.sql.models.HybridSecondaryUsage + :ivar hybrid_secondary_usage_detected: Hybrid secondary usage detected. Possible values are + 'Active' (customer does not meet the requirements to use the secondary as Passive DR) and + 'Passive' (customer meets the requirements to use the secondary as Passive DR). Known values + are: "Active" and "Passive". + :vartype hybrid_secondary_usage_detected: str or + ~azure.mgmt.sql.models.HybridSecondaryUsageDetected :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: 16384. Increments of 32 GB allowed only. Maximum value depends on the selected hardware family and number of vCores. :vartype storage_size_in_gb: int + :ivar storage_i_ops: Storage IOps. Minimum value: 120. Maximum value: 120000. Increments of 1 + IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. + :vartype storage_i_ops: int + :ivar storage_throughput_m_bps: Storage throughput in MBps. Minimum value: 25. Maximum value: + 4000. Increments of 1 MBps allowed only. Maximum value depends on the selected hardware family + and number of vCores. + :vartype storage_throughput_m_bps: int :ivar collation: Collation of the managed instance. :vartype collation: str :ivar dns_zone: The Dns Zone that the managed instance is in. @@ -10819,7 +11462,24 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator :ivar service_principal: The managed instance's service principal. :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal - """ + :ivar virtual_cluster_id: Virtual cluster resource id for the Managed Instance. + :vartype virtual_cluster_id: str + :ivar external_governance_status: Status of external governance. Known values are: "Enabled" + and "Disabled". + :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus + :ivar pricing_model: Weather or not Managed Instance is freemium. Known values are: "Regular" + and "Freemium". + :vartype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType + :ivar create_time: Specifies the point in time (ISO8601 format) of the Managed Instance + creation. + :vartype create_time: ~datetime.datetime + :ivar authentication_metadata: The managed instance's authentication metadata lookup mode. + Known values are: "AzureAD", "Paired", and "Windows". + :vartype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes + :ivar database_format: Specifies the internal format of instance databases specific to the SQL + engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". + :vartype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat + """ _validation = { "id": {"readonly": True}, @@ -10829,9 +11489,13 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att "provisioning_state": {"readonly": True}, "fully_qualified_domain_name": {"readonly": True}, "state": {"readonly": True}, + "hybrid_secondary_usage_detected": {"readonly": True}, "dns_zone": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, "current_backup_storage_redundancy": {"readonly": True}, + "virtual_cluster_id": {"readonly": True}, + "external_governance_status": {"readonly": True}, + "create_time": {"readonly": True}, } _attribute_map = { @@ -10845,13 +11509,18 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att "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"}, + "is_general_purpose_v2": {"key": "properties.isGeneralPurposeV2", "type": "bool"}, "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"}, + "hybrid_secondary_usage": {"key": "properties.hybridSecondaryUsage", "type": "str"}, + "hybrid_secondary_usage_detected": {"key": "properties.hybridSecondaryUsageDetected", "type": "str"}, "v_cores": {"key": "properties.vCores", "type": "int"}, "storage_size_in_gb": {"key": "properties.storageSizeInGB", "type": "int"}, + "storage_i_ops": {"key": "properties.storageIOps", "type": "int"}, + "storage_throughput_m_bps": {"key": "properties.storageThroughputMBps", "type": "int"}, "collation": {"key": "properties.collation", "type": "str"}, "dns_zone": {"key": "properties.dnsZone", "type": "str"}, "dns_zone_partner": {"key": "properties.dnsZonePartner", "type": "str"}, @@ -10874,6 +11543,12 @@ class ManagedInstance(TrackedResource): # pylint: disable=too-many-instance-att "key_id": {"key": "properties.keyId", "type": "str"}, "administrators": {"key": "properties.administrators", "type": "ManagedInstanceExternalAdministrator"}, "service_principal": {"key": "properties.servicePrincipal", "type": "ServicePrincipal"}, + "virtual_cluster_id": {"key": "properties.virtualClusterId", "type": "str"}, + "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, + "pricing_model": {"key": "properties.pricingModel", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "authentication_metadata": {"key": "properties.authenticationMetadata", "type": "str"}, + "database_format": {"key": "properties.databaseFormat", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -10884,12 +11559,16 @@ def __init__( # pylint: disable=too-many-locals identity: Optional["_models.ResourceIdentity"] = None, sku: Optional["_models.Sku"] = None, managed_instance_create_mode: Optional[Union[str, "_models.ManagedServerCreateMode"]] = None, + is_general_purpose_v2: Optional[bool] = None, administrator_login: Optional[str] = None, administrator_login_password: Optional[str] = None, subnet_id: Optional[str] = None, license_type: Optional[Union[str, "_models.ManagedInstanceLicenseType"]] = None, + hybrid_secondary_usage: Optional[Union[str, "_models.HybridSecondaryUsage"]] = None, v_cores: Optional[int] = None, storage_size_in_gb: Optional[int] = None, + storage_i_ops: Optional[int] = None, + storage_throughput_m_bps: Optional[int] = None, collation: Optional[str] = None, dns_zone_partner: Optional[str] = None, public_data_endpoint_enabled: Optional[bool] = None, @@ -10906,6 +11585,9 @@ def __init__( # pylint: disable=too-many-locals key_id: Optional[str] = None, administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = None, service_principal: Optional["_models.ServicePrincipal"] = None, + pricing_model: Optional[Union[str, "_models.FreemiumType"]] = None, + authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = None, + database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = None, **kwargs: Any ) -> None: """ @@ -10926,6 +11608,9 @@ def __init__( # pylint: disable=too-many-locals RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: "Default" and "PointInTimeRestore". :paramtype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :keyword is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose + edition. + :paramtype is_general_purpose_v2: bool :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 @@ -10938,12 +11623,24 @@ def __init__( # pylint: disable=too-many-locals inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Known values are: "LicenseIncluded" and "BasePrice". :paramtype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :keyword hybrid_secondary_usage: Hybrid secondary usage. Possible values are 'Active' (default + value) and 'Passive' (customer uses the secondary as Passive DR). Known values are: "Active" + and "Passive". + :paramtype hybrid_secondary_usage: str or ~azure.mgmt.sql.models.HybridSecondaryUsage :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: 16384. Increments of 32 GB allowed only. Maximum value depends on the selected hardware family and number of vCores. :paramtype storage_size_in_gb: int + :keyword storage_i_ops: Storage IOps. Minimum value: 120. Maximum value: 120000. Increments of + 1 IOps allowed only. Maximum value depends on the selected hardware family and number of + vCores. + :paramtype storage_i_ops: int + :keyword storage_throughput_m_bps: Storage throughput in MBps. Minimum value: 25. Maximum + value: 4000. Increments of 1 MBps allowed only. Maximum value depends on the selected hardware + family and number of vCores. + :paramtype storage_throughput_m_bps: 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 @@ -10995,6 +11692,15 @@ def __init__( # pylint: disable=too-many-locals :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator :keyword service_principal: The managed instance's service principal. :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :keyword pricing_model: Weather or not Managed Instance is freemium. Known values are: + "Regular" and "Freemium". + :paramtype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType + :keyword authentication_metadata: The managed instance's authentication metadata lookup mode. + Known values are: "AzureAD", "Paired", and "Windows". + :paramtype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes + :keyword database_format: Specifies the internal format of instance databases specific to the + SQL engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". + :paramtype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat """ super().__init__(location=location, tags=tags, **kwargs) self.identity = identity @@ -11002,13 +11708,18 @@ def __init__( # pylint: disable=too-many-locals self.provisioning_state = None self.managed_instance_create_mode = managed_instance_create_mode self.fully_qualified_domain_name = None + self.is_general_purpose_v2 = is_general_purpose_v2 self.administrator_login = administrator_login self.administrator_login_password = administrator_login_password self.subnet_id = subnet_id self.state = None self.license_type = license_type + self.hybrid_secondary_usage = hybrid_secondary_usage + self.hybrid_secondary_usage_detected = None self.v_cores = v_cores self.storage_size_in_gb = storage_size_in_gb + self.storage_i_ops = storage_i_ops + self.storage_throughput_m_bps = storage_throughput_m_bps self.collation = collation self.dns_zone = None self.dns_zone_partner = dns_zone_partner @@ -11028,6 +11739,12 @@ def __init__( # pylint: disable=too-many-locals self.key_id = key_id self.administrators = administrators self.service_principal = service_principal + self.virtual_cluster_id = None + self.external_governance_status = None + self.pricing_model = pricing_model + self.create_time = None + self.authentication_metadata = authentication_metadata + self.database_format = database_format class ManagedInstanceAdministrator(ProxyResource): @@ -11473,13 +12190,13 @@ class ManagedInstanceEditionCapability(_serialization.Model): :ivar name: The managed server version name. :vartype name: str + :ivar is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose edition. + :vartype is_general_purpose_v2: bool :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. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -11489,17 +12206,17 @@ class ManagedInstanceEditionCapability(_serialization.Model): _validation = { "name": {"readonly": True}, + "is_general_purpose_v2": {"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"}, + "is_general_purpose_v2": {"key": "isGeneralPurposeV2", "type": "bool"}, "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"}, } @@ -11511,9 +12228,9 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: """ super().__init__(**kwargs) self.name = None + self.is_general_purpose_v2 = None self.supported_families = None self.supported_storage_capabilities = None - self.zone_redundant = None self.status = None self.reason = reason @@ -11691,6 +12408,8 @@ class ManagedInstanceFamilyCapability(_serialization.Model): :vartype name: str :ivar sku: SKU name. :vartype sku: str + :ivar zone_redundant: Whether or not zone redundancy is supported for the family. + :vartype zone_redundant: bool :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. @@ -11705,6 +12424,7 @@ class ManagedInstanceFamilyCapability(_serialization.Model): _validation = { "name": {"readonly": True}, "sku": {"readonly": True}, + "zone_redundant": {"readonly": True}, "supported_license_types": {"readonly": True}, "supported_vcores_values": {"readonly": True}, "status": {"readonly": True}, @@ -11713,6 +12433,7 @@ class ManagedInstanceFamilyCapability(_serialization.Model): _attribute_map = { "name": {"key": "name", "type": "str"}, "sku": {"key": "sku", "type": "str"}, + "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, "supported_license_types": {"key": "supportedLicenseTypes", "type": "[LicenseTypeCapability]"}, "supported_vcores_values": {"key": "supportedVcoresValues", "type": "[ManagedInstanceVcoresCapability]"}, "status": {"key": "status", "type": "str"}, @@ -11727,6 +12448,7 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: super().__init__(**kwargs) self.name = None self.sku = None + self.zone_redundant = None self.supported_license_types = None self.supported_vcores_values = None self.status = None @@ -11862,7 +12584,7 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ManagedInstanceLongTermRetentionBackup(ProxyResource): +class ManagedInstanceLongTermRetentionBackup(ProxyResource): # pylint: disable=too-many-instance-attributes """A long term retention backup for a managed database. Variables are only populated by the server, and will be ignored when sending a request. @@ -11888,6 +12610,9 @@ class ManagedInstanceLongTermRetentionBackup(ProxyResource): :ivar backup_storage_redundancy: The storage redundancy type of the backup. Known values are: "Geo", "Local", "Zone", and "GeoZone". :vartype backup_storage_redundancy: str or ~azure.mgmt.sql.models.BackupStorageRedundancy + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backup. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier """ _validation = { @@ -11901,6 +12626,7 @@ class ManagedInstanceLongTermRetentionBackup(ProxyResource): "backup_time": {"readonly": True}, "backup_expiration_time": {"readonly": True}, "backup_storage_redundancy": {"readonly": True}, + "backup_storage_access_tier": {"readonly": True}, } _attribute_map = { @@ -11914,6 +12640,7 @@ class ManagedInstanceLongTermRetentionBackup(ProxyResource): "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"}, + "backup_storage_access_tier": {"key": "properties.backupStorageAccessTier", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: @@ -11926,6 +12653,7 @@ def __init__(self, **kwargs: Any) -> None: self.backup_time = None self.backup_expiration_time = None self.backup_storage_redundancy = None + self.backup_storage_access_tier = None class ManagedInstanceLongTermRetentionBackupListResult(_serialization.Model): @@ -11967,13 +12695,16 @@ class ManagedInstanceLongTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :ivar backup_storage_access_tier: The BackupStorageAccessTier for the LTR backups. Known values + are: "Hot" and "Archive". + :vartype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier + :ivar weekly_retention: The weekly retention policy for an LTR backup. :vartype weekly_retention: str - :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. + :ivar monthly_retention: The monthly retention policy for an LTR backup. :vartype monthly_retention: str - :ivar yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :ivar yearly_retention: The yearly retention policy for an LTR backup. :vartype yearly_retention: str - :ivar week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :ivar week_of_year: The week of year to take the yearly backup. :vartype week_of_year: int """ @@ -11987,6 +12718,7 @@ class ManagedInstanceLongTermRetentionPolicy(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "backup_storage_access_tier": {"key": "properties.backupStorageAccessTier", "type": "str"}, "weekly_retention": {"key": "properties.weeklyRetention", "type": "str"}, "monthly_retention": {"key": "properties.monthlyRetention", "type": "str"}, "yearly_retention": {"key": "properties.yearlyRetention", "type": "str"}, @@ -11996,6 +12728,7 @@ class ManagedInstanceLongTermRetentionPolicy(ProxyResource): def __init__( self, *, + backup_storage_access_tier: Optional[Union[str, "_models.BackupStorageAccessTier"]] = None, weekly_retention: Optional[str] = None, monthly_retention: Optional[str] = None, yearly_retention: Optional[str] = None, @@ -12003,17 +12736,20 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :keyword backup_storage_access_tier: The BackupStorageAccessTier for the LTR backups. Known + values are: "Hot" and "Archive". + :paramtype backup_storage_access_tier: str or ~azure.mgmt.sql.models.BackupStorageAccessTier + :keyword weekly_retention: The weekly retention policy for an LTR backup. :paramtype weekly_retention: str - :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 - format. + :keyword monthly_retention: The monthly retention policy for an LTR backup. :paramtype monthly_retention: str - :keyword yearly_retention: The yearly retention policy for an LTR backup in an ISO 8601 format. + :keyword yearly_retention: The yearly retention policy for an LTR backup. :paramtype yearly_retention: str - :keyword week_of_year: The week of year to take the yearly backup in an ISO 8601 format. + :keyword week_of_year: The week of year to take the yearly backup. :paramtype week_of_year: int """ super().__init__(**kwargs) + self.backup_storage_access_tier = backup_storage_access_tier self.weekly_retention = weekly_retention self.monthly_retention = monthly_retention self.yearly_retention = yearly_retention @@ -12260,7 +12996,8 @@ class ManagedInstanceOperationSteps(_serialization.Model): :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] + :vartype steps_list: + list[~azure.mgmt.sql.models.UpsertManagedServerOperationStepWithEstimatesAndDuration] """ _validation = { @@ -12272,7 +13009,7 @@ class ManagedInstanceOperationSteps(_serialization.Model): _attribute_map = { "total_steps": {"key": "totalSteps", "type": "str"}, "current_step": {"key": "currentStep", "type": "int"}, - "steps_list": {"key": "stepsList", "type": "[UpsertManagedServerOperationStep]"}, + "steps_list": {"key": "stepsList", "type": "[UpsertManagedServerOperationStepWithEstimatesAndDuration]"}, } def __init__(self, **kwargs: Any) -> None: @@ -12577,16 +13314,20 @@ class ManagedInstancePrivateLinkProperties(_serialization.Model): :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: Any) -> None: @@ -12594,6 +13335,7 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.group_id = None self.required_members = None + self.required_zone_names = None class ManagedInstancePrivateLinkServiceConnectionStateProperty(_serialization.Model): @@ -12712,11 +13454,9 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i :vartype identity: ~azure.mgmt.sql.models.ResourceIdentity :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar provisioning_state: Known values are: "Creating", "Deleting", "Updating", "Unknown", - "Succeeded", "Failed", "Accepted", "Created", "Deleted", "Unrecognized", "Running", "Canceled", - "NotSpecified", "Registering", and "TimedOut". - :vartype provisioning_state: str or - ~azure.mgmt.sql.models.ManagedInstancePropertiesProvisioningState + :ivar provisioning_state: Provisioning state of managed instance. Known values are: "Created", + "InProgress", "Succeeded", "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.sql.models.ProvisioningState :ivar managed_instance_create_mode: Specifies the mode of database creation. Default: Regular instance creation. @@ -12727,6 +13467,8 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i :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 + :ivar is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose edition. + :vartype is_general_purpose_v2: bool :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). :vartype administrator_login: str @@ -12741,12 +13483,29 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Known values are: "LicenseIncluded" and "BasePrice". :vartype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :ivar hybrid_secondary_usage: Hybrid secondary usage. Possible values are 'Active' (default + value) and 'Passive' (customer uses the secondary as Passive DR). Known values are: "Active" + and "Passive". + :vartype hybrid_secondary_usage: str or ~azure.mgmt.sql.models.HybridSecondaryUsage + :ivar hybrid_secondary_usage_detected: Hybrid secondary usage detected. Possible values are + 'Active' (customer does not meet the requirements to use the secondary as Passive DR) and + 'Passive' (customer meets the requirements to use the secondary as Passive DR). Known values + are: "Active" and "Passive". + :vartype hybrid_secondary_usage_detected: str or + ~azure.mgmt.sql.models.HybridSecondaryUsageDetected :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: 16384. Increments of 32 GB allowed only. Maximum value depends on the selected hardware family and number of vCores. :vartype storage_size_in_gb: int + :ivar storage_i_ops: Storage IOps. Minimum value: 120. Maximum value: 120000. Increments of 1 + IOps allowed only. Maximum value depends on the selected hardware family and number of vCores. + :vartype storage_i_ops: int + :ivar storage_throughput_m_bps: Storage throughput in MBps. Minimum value: 25. Maximum value: + 4000. Increments of 1 MBps allowed only. Maximum value depends on the selected hardware family + and number of vCores. + :vartype storage_throughput_m_bps: int :ivar collation: Collation of the managed instance. :vartype collation: str :ivar dns_zone: The Dns Zone that the managed instance is in. @@ -12808,15 +13567,36 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i :vartype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator :ivar service_principal: The managed instance's service principal. :vartype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :ivar virtual_cluster_id: Virtual cluster resource id for the Managed Instance. + :vartype virtual_cluster_id: str + :ivar external_governance_status: Status of external governance. Known values are: "Enabled" + and "Disabled". + :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus + :ivar pricing_model: Weather or not Managed Instance is freemium. Known values are: "Regular" + and "Freemium". + :vartype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType + :ivar create_time: Specifies the point in time (ISO8601 format) of the Managed Instance + creation. + :vartype create_time: ~datetime.datetime + :ivar authentication_metadata: The managed instance's authentication metadata lookup mode. + Known values are: "AzureAD", "Paired", and "Windows". + :vartype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes + :ivar database_format: Specifies the internal format of instance databases specific to the SQL + engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". + :vartype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat """ _validation = { "provisioning_state": {"readonly": True}, "fully_qualified_domain_name": {"readonly": True}, "state": {"readonly": True}, + "hybrid_secondary_usage_detected": {"readonly": True}, "dns_zone": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, "current_backup_storage_redundancy": {"readonly": True}, + "virtual_cluster_id": {"readonly": True}, + "external_governance_status": {"readonly": True}, + "create_time": {"readonly": True}, } _attribute_map = { @@ -12826,13 +13606,18 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i "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"}, + "is_general_purpose_v2": {"key": "properties.isGeneralPurposeV2", "type": "bool"}, "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"}, + "hybrid_secondary_usage": {"key": "properties.hybridSecondaryUsage", "type": "str"}, + "hybrid_secondary_usage_detected": {"key": "properties.hybridSecondaryUsageDetected", "type": "str"}, "v_cores": {"key": "properties.vCores", "type": "int"}, "storage_size_in_gb": {"key": "properties.storageSizeInGB", "type": "int"}, + "storage_i_ops": {"key": "properties.storageIOps", "type": "int"}, + "storage_throughput_m_bps": {"key": "properties.storageThroughputMBps", "type": "int"}, "collation": {"key": "properties.collation", "type": "str"}, "dns_zone": {"key": "properties.dnsZone", "type": "str"}, "dns_zone_partner": {"key": "properties.dnsZonePartner", "type": "str"}, @@ -12855,6 +13640,12 @@ class ManagedInstanceUpdate(_serialization.Model): # pylint: disable=too-many-i "key_id": {"key": "properties.keyId", "type": "str"}, "administrators": {"key": "properties.administrators", "type": "ManagedInstanceExternalAdministrator"}, "service_principal": {"key": "properties.servicePrincipal", "type": "ServicePrincipal"}, + "virtual_cluster_id": {"key": "properties.virtualClusterId", "type": "str"}, + "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, + "pricing_model": {"key": "properties.pricingModel", "type": "str"}, + "create_time": {"key": "properties.createTime", "type": "iso-8601"}, + "authentication_metadata": {"key": "properties.authenticationMetadata", "type": "str"}, + "database_format": {"key": "properties.databaseFormat", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -12864,12 +13655,16 @@ def __init__( # pylint: disable=too-many-locals identity: Optional["_models.ResourceIdentity"] = None, tags: Optional[Dict[str, str]] = None, managed_instance_create_mode: Optional[Union[str, "_models.ManagedServerCreateMode"]] = None, + is_general_purpose_v2: Optional[bool] = None, administrator_login: Optional[str] = None, administrator_login_password: Optional[str] = None, subnet_id: Optional[str] = None, license_type: Optional[Union[str, "_models.ManagedInstanceLicenseType"]] = None, + hybrid_secondary_usage: Optional[Union[str, "_models.HybridSecondaryUsage"]] = None, v_cores: Optional[int] = None, storage_size_in_gb: Optional[int] = None, + storage_i_ops: Optional[int] = None, + storage_throughput_m_bps: Optional[int] = None, collation: Optional[str] = None, dns_zone_partner: Optional[str] = None, public_data_endpoint_enabled: Optional[bool] = None, @@ -12886,6 +13681,9 @@ def __init__( # pylint: disable=too-many-locals key_id: Optional[str] = None, administrators: Optional["_models.ManagedInstanceExternalAdministrator"] = None, service_principal: Optional["_models.ServicePrincipal"] = None, + pricing_model: Optional[Union[str, "_models.FreemiumType"]] = None, + authentication_metadata: Optional[Union[str, "_models.AuthMetadataLookupModes"]] = None, + database_format: Optional[Union[str, "_models.ManagedInstanceDatabaseFormat"]] = None, **kwargs: Any ) -> None: """ @@ -12903,6 +13701,9 @@ def __init__( # pylint: disable=too-many-locals RestorePointInTime and SourceManagedInstanceId must be specified. Known values are: "Default" and "PointInTimeRestore". :paramtype managed_instance_create_mode: str or ~azure.mgmt.sql.models.ManagedServerCreateMode + :keyword is_general_purpose_v2: Whether or not this is a GPv2 variant of General Purpose + edition. + :paramtype is_general_purpose_v2: bool :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 @@ -12915,12 +13716,24 @@ def __init__( # pylint: disable=too-many-locals inclusive of a new SQL license) and 'BasePrice' (discounted AHB price for bringing your own SQL licenses). Known values are: "LicenseIncluded" and "BasePrice". :paramtype license_type: str or ~azure.mgmt.sql.models.ManagedInstanceLicenseType + :keyword hybrid_secondary_usage: Hybrid secondary usage. Possible values are 'Active' (default + value) and 'Passive' (customer uses the secondary as Passive DR). Known values are: "Active" + and "Passive". + :paramtype hybrid_secondary_usage: str or ~azure.mgmt.sql.models.HybridSecondaryUsage :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: 16384. Increments of 32 GB allowed only. Maximum value depends on the selected hardware family and number of vCores. :paramtype storage_size_in_gb: int + :keyword storage_i_ops: Storage IOps. Minimum value: 120. Maximum value: 120000. Increments of + 1 IOps allowed only. Maximum value depends on the selected hardware family and number of + vCores. + :paramtype storage_i_ops: int + :keyword storage_throughput_m_bps: Storage throughput in MBps. Minimum value: 25. Maximum + value: 4000. Increments of 1 MBps allowed only. Maximum value depends on the selected hardware + family and number of vCores. + :paramtype storage_throughput_m_bps: 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 @@ -12972,6 +13785,15 @@ def __init__( # pylint: disable=too-many-locals :paramtype administrators: ~azure.mgmt.sql.models.ManagedInstanceExternalAdministrator :keyword service_principal: The managed instance's service principal. :paramtype service_principal: ~azure.mgmt.sql.models.ServicePrincipal + :keyword pricing_model: Weather or not Managed Instance is freemium. Known values are: + "Regular" and "Freemium". + :paramtype pricing_model: str or ~azure.mgmt.sql.models.FreemiumType + :keyword authentication_metadata: The managed instance's authentication metadata lookup mode. + Known values are: "AzureAD", "Paired", and "Windows". + :paramtype authentication_metadata: str or ~azure.mgmt.sql.models.AuthMetadataLookupModes + :keyword database_format: Specifies the internal format of instance databases specific to the + SQL engine version. Known values are: "AlwaysUpToDate" and "SQLServer2022". + :paramtype database_format: str or ~azure.mgmt.sql.models.ManagedInstanceDatabaseFormat """ super().__init__(**kwargs) self.sku = sku @@ -12980,13 +13802,18 @@ def __init__( # pylint: disable=too-many-locals self.provisioning_state = None self.managed_instance_create_mode = managed_instance_create_mode self.fully_qualified_domain_name = None + self.is_general_purpose_v2 = is_general_purpose_v2 self.administrator_login = administrator_login self.administrator_login_password = administrator_login_password self.subnet_id = subnet_id self.state = None self.license_type = license_type + self.hybrid_secondary_usage = hybrid_secondary_usage + self.hybrid_secondary_usage_detected = None self.v_cores = v_cores self.storage_size_in_gb = storage_size_in_gb + self.storage_i_ops = storage_i_ops + self.storage_throughput_m_bps = storage_throughput_m_bps self.collation = collation self.dns_zone = None self.dns_zone_partner = dns_zone_partner @@ -13006,9 +13833,15 @@ def __init__( # pylint: disable=too-many-locals self.key_id = key_id self.administrators = administrators self.service_principal = service_principal + self.virtual_cluster_id = None + self.external_governance_status = None + self.pricing_model = pricing_model + self.create_time = None + self.authentication_metadata = authentication_metadata + self.database_format = database_format -class ManagedInstanceVcoresCapability(_serialization.Model): +class ManagedInstanceVcoresCapability(_serialization.Model): # pylint: disable=too-many-instance-attributes """The managed instance virtual cores capability. Variables are only populated by the server, and will be ignored when sending a request. @@ -13021,6 +13854,26 @@ class ManagedInstanceVcoresCapability(_serialization.Model): :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 included_storage_i_ops: Included storage IOps. + :vartype included_storage_i_ops: int + :ivar supported_storage_i_ops: Storage IOps ranges. + :vartype supported_storage_i_ops: ~azure.mgmt.sql.models.MaxLimitRangeCapability + :ivar iops_min_value_override_factor_per_selected_storage_gb: Min IOps override factor per + selected storage GB. + :vartype iops_min_value_override_factor_per_selected_storage_gb: float + :ivar iops_included_value_override_factor_per_selected_storage_gb: Included IOps override + factor per selected storage GB. + :vartype iops_included_value_override_factor_per_selected_storage_gb: float + :ivar included_storage_throughput_m_bps: Included storage throughput MBps. + :vartype included_storage_throughput_m_bps: int + :ivar supported_storage_throughput_m_bps: Storage throughput MBps ranges. + :vartype supported_storage_throughput_m_bps: ~azure.mgmt.sql.models.MaxLimitRangeCapability + :ivar throughput_m_bps_min_value_override_factor_per_selected_storage_gb: Min throughput MBps + override factor per selected storage GB. + :vartype throughput_m_bps_min_value_override_factor_per_selected_storage_gb: float + :ivar throughput_m_bps_included_value_override_factor_per_selected_storage_gb: Included + throughput MBps override factor per selected storage GB. + :vartype throughput_m_bps_included_value_override_factor_per_selected_storage_gb: float :ivar instance_pool_supported: True if this service objective is supported for managed instances in an instance pool. :vartype instance_pool_supported: bool @@ -13042,6 +13895,14 @@ class ManagedInstanceVcoresCapability(_serialization.Model): "value": {"readonly": True}, "included_max_size": {"readonly": True}, "supported_storage_sizes": {"readonly": True}, + "included_storage_i_ops": {"readonly": True}, + "supported_storage_i_ops": {"readonly": True}, + "iops_min_value_override_factor_per_selected_storage_gb": {"readonly": True}, + "iops_included_value_override_factor_per_selected_storage_gb": {"readonly": True}, + "included_storage_throughput_m_bps": {"readonly": True}, + "supported_storage_throughput_m_bps": {"readonly": True}, + "throughput_m_bps_min_value_override_factor_per_selected_storage_gb": {"readonly": True}, + "throughput_m_bps_included_value_override_factor_per_selected_storage_gb": {"readonly": True}, "instance_pool_supported": {"readonly": True}, "standalone_supported": {"readonly": True}, "supported_maintenance_configurations": {"readonly": True}, @@ -13053,6 +13914,29 @@ class ManagedInstanceVcoresCapability(_serialization.Model): "value": {"key": "value", "type": "int"}, "included_max_size": {"key": "includedMaxSize", "type": "MaxSizeCapability"}, "supported_storage_sizes": {"key": "supportedStorageSizes", "type": "[MaxSizeRangeCapability]"}, + "included_storage_i_ops": {"key": "includedStorageIOps", "type": "int"}, + "supported_storage_i_ops": {"key": "supportedStorageIOps", "type": "MaxLimitRangeCapability"}, + "iops_min_value_override_factor_per_selected_storage_gb": { + "key": "iopsMinValueOverrideFactorPerSelectedStorageGB", + "type": "float", + }, + "iops_included_value_override_factor_per_selected_storage_gb": { + "key": "iopsIncludedValueOverrideFactorPerSelectedStorageGB", + "type": "float", + }, + "included_storage_throughput_m_bps": {"key": "includedStorageThroughputMBps", "type": "int"}, + "supported_storage_throughput_m_bps": { + "key": "supportedStorageThroughputMBps", + "type": "MaxLimitRangeCapability", + }, + "throughput_m_bps_min_value_override_factor_per_selected_storage_gb": { + "key": "throughputMBpsMinValueOverrideFactorPerSelectedStorageGB", + "type": "float", + }, + "throughput_m_bps_included_value_override_factor_per_selected_storage_gb": { + "key": "throughputMBpsIncludedValueOverrideFactorPerSelectedStorageGB", + "type": "float", + }, "instance_pool_supported": {"key": "instancePoolSupported", "type": "bool"}, "standalone_supported": {"key": "standaloneSupported", "type": "bool"}, "supported_maintenance_configurations": { @@ -13073,6 +13957,14 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.value = None self.included_max_size = None self.supported_storage_sizes = None + self.included_storage_i_ops = None + self.supported_storage_i_ops = None + self.iops_min_value_override_factor_per_selected_storage_gb = None + self.iops_included_value_override_factor_per_selected_storage_gb = None + self.included_storage_throughput_m_bps = None + self.supported_storage_throughput_m_bps = None + self.throughput_m_bps_min_value_override_factor_per_selected_storage_gb = None + self.throughput_m_bps_included_value_override_factor_per_selected_storage_gb = None self.instance_pool_supported = None self.standalone_supported = None self.supported_maintenance_configurations = None @@ -13634,6 +14526,53 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None +class MaxLimitRangeCapability(_serialization.Model): + """The maximum limit 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: int + :ivar max_value: Maximum value. + :vartype max_value: int + :ivar scale_size: Scale/step size for discrete values between the minimum value and the maximum + value. + :vartype scale_size: int + :ivar status: The status of the capability. Known values are: "Visible", "Available", + "Default", and "Disabled". + :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus + :ivar reason: The reason for the capability not being available. + :vartype reason: str + """ + + _validation = { + "min_value": {"readonly": True}, + "max_value": {"readonly": True}, + "scale_size": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "min_value": {"key": "minValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, + "scale_size": {"key": "scaleSize", "type": "int"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword reason: The reason for the capability not being available. + :paramtype reason: str + """ + super().__init__(**kwargs) + self.min_value = None + self.max_value = None + self.scale_size = None + self.status = None + self.reason = reason + + class MaxSizeCapability(_serialization.Model): """The maximum size capability. @@ -13715,256 +14654,6 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.reason = reason -class Metric(_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. Known values are: "count", "bytes", "seconds", "percent", - "countPerSecond", and "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: Any) -> None: - """ """ - super().__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(_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.retention = None - self.time_grain = None - - -class MetricDefinition(_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. Known values are: "None", "Average", "Count", "Minimum", "Maximum", and "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. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", and "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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.primary_aggregation_type = None - self.resource_uri = None - self.unit = None - self.metric_availabilities = None - - -class MetricDefinitionListResult(_serialization.Model): - """The response to a list database metric definitions request. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The list of metric definitions for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.MetricDefinition] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, - } - - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: The list of metric definitions for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.MetricDefinition] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricListResult(_serialization.Model): - """The response to a list database metrics request. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The list of metrics for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.Metric] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Metric]"}, - } - - def __init__(self, *, value: List["_models.Metric"], **kwargs: Any) -> None: - """ - :keyword value: The list of metrics for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.Metric] - """ - super().__init__(**kwargs) - self.value = value - - -class MetricName(_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.localized_value = None - - -class MetricValue(_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.count = None - self.average = None - self.maximum = None - self.minimum = None - self.timestamp = None - self.total = None - - class MinCapacityCapability(_serialization.Model): """The min capacity capability. @@ -14067,44 +14756,420 @@ def __init__( self.sql_server_resource_id = sql_server_resource_id -class NetworkIsolationSettingsAutoGenerated(_serialization.Model): - """Contains the ARM resources for which to create private endpoint connection. +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """NSP Configuration for a server. - :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. - :vartype sql_server_resource_id: str + 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: + :vartype provisioning_state: str + :ivar network_security_perimeter: + :vartype network_security_perimeter: ~azure.mgmt.sql.models.NSPConfigPerimeter + :ivar resource_association: + :vartype resource_association: ~azure.mgmt.sql.models.NSPConfigAssociation + :ivar profile: + :vartype profile: ~azure.mgmt.sql.models.NSPConfigProfile + :ivar provisioning_issues: + :vartype provisioning_issues: list[~azure.mgmt.sql.models.NSPProvisioningIssue] """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + _attribute_map = { - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "network_security_perimeter": {"key": "properties.networkSecurityPerimeter", "type": "NSPConfigPerimeter"}, + "resource_association": {"key": "properties.resourceAssociation", "type": "NSPConfigAssociation"}, + "profile": {"key": "properties.profile", "type": "NSPConfigProfile"}, + "provisioning_issues": {"key": "properties.provisioningIssues", "type": "[NSPProvisioningIssue]"}, } def __init__( self, *, - storage_account_resource_id: Optional[str] = None, - sql_server_resource_id: Optional[str] = None, + provisioning_state: Optional[str] = None, + network_security_perimeter: Optional["_models.NSPConfigPerimeter"] = None, + resource_association: Optional["_models.NSPConfigAssociation"] = None, + profile: Optional["_models.NSPConfigProfile"] = None, + provisioning_issues: Optional[List["_models.NSPProvisioningIssue"]] = None, **kwargs: Any ) -> None: """ - :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 + :keyword provisioning_state: + :paramtype provisioning_state: str + :keyword network_security_perimeter: + :paramtype network_security_perimeter: ~azure.mgmt.sql.models.NSPConfigPerimeter + :keyword resource_association: + :paramtype resource_association: ~azure.mgmt.sql.models.NSPConfigAssociation + :keyword profile: + :paramtype profile: ~azure.mgmt.sql.models.NSPConfigProfile + :keyword provisioning_issues: + :paramtype provisioning_issues: list[~azure.mgmt.sql.models.NSPProvisioningIssue] """ super().__init__(**kwargs) - self.storage_account_resource_id = storage_account_resource_id - self.sql_server_resource_id = sql_server_resource_id + self.provisioning_state = provisioning_state + self.network_security_perimeter = network_security_perimeter + self.resource_association = resource_association + self.profile = profile + self.provisioning_issues = provisioning_issues + + +class NetworkSecurityPerimeterConfigurationListResult(_serialization.Model): + """A list of NSP configurations for a server. + + 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.NetworkSecurityPerimeterConfiguration] + :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": "[NetworkSecurityPerimeterConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class NSPConfigAccessRule(_serialization.Model): + """NSPConfigAccessRule. + + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NSPConfigAccessRuleProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPConfigAccessRuleProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: + :paramtype name: str + :keyword properties: + :paramtype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties + """ + super().__init__(**kwargs) + self.name = name + self.properties = properties + + +class NSPConfigAccessRuleProperties(_serialization.Model): + """NSPConfigAccessRuleProperties. + + :ivar direction: + :vartype direction: str + :ivar address_prefixes: + :vartype address_prefixes: list[str] + :ivar fully_qualified_domain_names: + :vartype fully_qualified_domain_names: list[str] + :ivar subscriptions: + :vartype subscriptions: list[str] + :ivar network_security_perimeters: + :vartype network_security_perimeters: + list[~azure.mgmt.sql.models.NSPConfigNetworkSecurityPerimeterRule] + """ + + _attribute_map = { + "direction": {"key": "direction", "type": "str"}, + "address_prefixes": {"key": "addressPrefixes", "type": "[str]"}, + "fully_qualified_domain_names": {"key": "fullyQualifiedDomainNames", "type": "[str]"}, + "subscriptions": {"key": "subscriptions", "type": "[str]"}, + "network_security_perimeters": { + "key": "networkSecurityPerimeters", + "type": "[NSPConfigNetworkSecurityPerimeterRule]", + }, + } + + def __init__( + self, + *, + direction: Optional[str] = None, + address_prefixes: Optional[List[str]] = None, + fully_qualified_domain_names: Optional[List[str]] = None, + subscriptions: Optional[List[str]] = None, + network_security_perimeters: Optional[List["_models.NSPConfigNetworkSecurityPerimeterRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword direction: + :paramtype direction: str + :keyword address_prefixes: + :paramtype address_prefixes: list[str] + :keyword fully_qualified_domain_names: + :paramtype fully_qualified_domain_names: list[str] + :keyword subscriptions: + :paramtype subscriptions: list[str] + :keyword network_security_perimeters: + :paramtype network_security_perimeters: + list[~azure.mgmt.sql.models.NSPConfigNetworkSecurityPerimeterRule] + """ + super().__init__(**kwargs) + self.direction = direction + self.address_prefixes = address_prefixes + self.fully_qualified_domain_names = fully_qualified_domain_names + self.subscriptions = subscriptions + self.network_security_perimeters = network_security_perimeters + + +class NSPConfigAssociation(_serialization.Model): + """NSPConfigAssociation. + + :ivar name: + :vartype name: str + :ivar access_mode: + :vartype access_mode: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_mode": {"key": "accessMode", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, access_mode: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: + :paramtype name: str + :keyword access_mode: + :paramtype access_mode: str + """ + super().__init__(**kwargs) + self.name = name + self.access_mode = access_mode + + +class NSPConfigNetworkSecurityPerimeterRule(_serialization.Model): + """NSPConfigNetworkSecurityPerimeterRule. + + :ivar id: + :vartype id: str + :ivar perimeter_guid: + :vartype perimeter_guid: str + :ivar location: + :vartype location: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: + :paramtype id: str + :keyword perimeter_guid: + :paramtype perimeter_guid: str + :keyword location: + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location + + +class NSPConfigPerimeter(_serialization.Model): + """NSPConfigPerimeter. + + :ivar id: + :vartype id: str + :ivar perimeter_guid: + :vartype perimeter_guid: str + :ivar location: + :vartype location: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: + :paramtype id: str + :keyword perimeter_guid: + :paramtype perimeter_guid: str + :keyword location: + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location + + +class NSPConfigProfile(_serialization.Model): + """NSPConfigProfile. + + :ivar name: + :vartype name: str + :ivar access_rules_version: + :vartype access_rules_version: str + :ivar access_rules: + :vartype access_rules: list[~azure.mgmt.sql.models.NSPConfigAccessRule] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_rules_version": {"key": "accessRulesVersion", "type": "str"}, + "access_rules": {"key": "accessRules", "type": "[NSPConfigAccessRule]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[str] = None, + access_rules: Optional[List["_models.NSPConfigAccessRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: + :paramtype name: str + :keyword access_rules_version: + :paramtype access_rules_version: str + :keyword access_rules: + :paramtype access_rules: list[~azure.mgmt.sql.models.NSPConfigAccessRule] + """ + super().__init__(**kwargs) + self.name = name + self.access_rules_version = access_rules_version + self.access_rules = access_rules + + +class NSPProvisioningIssue(_serialization.Model): + """NSPProvisioningIssue. + + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NSPProvisioningIssueProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPProvisioningIssueProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: + :paramtype name: str + :keyword properties: + :paramtype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties + """ + super().__init__(**kwargs) + self.name = name + self.properties = properties + + +class NSPProvisioningIssueProperties(_serialization.Model): + """NSPProvisioningIssueProperties. + + :ivar issue_type: + :vartype issue_type: str + :ivar severity: + :vartype severity: str + :ivar description: + :vartype description: str + :ivar suggested_resource_ids: + :vartype suggested_resource_ids: list[str] + :ivar suggested_access_rules: + :vartype suggested_access_rules: list[str] + """ + + _attribute_map = { + "issue_type": {"key": "issueType", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "suggested_resource_ids": {"key": "suggestedResourceIds", "type": "[str]"}, + "suggested_access_rules": {"key": "suggestedAccessRules", "type": "[str]"}, + } + + def __init__( + self, + *, + issue_type: Optional[str] = None, + severity: Optional[str] = None, + description: Optional[str] = None, + suggested_resource_ids: Optional[List[str]] = None, + suggested_access_rules: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword issue_type: + :paramtype issue_type: str + :keyword severity: + :paramtype severity: str + :keyword description: + :paramtype description: str + :keyword suggested_resource_ids: + :paramtype suggested_resource_ids: list[str] + :keyword suggested_access_rules: + :paramtype suggested_access_rules: list[str] + """ + super().__init__(**kwargs) + self.issue_type = issue_type + self.severity = severity + self.description = description + self.suggested_resource_ids = suggested_resource_ids + self.suggested_access_rules = suggested_access_rules class Operation(_serialization.Model): @@ -14184,44 +15249,6 @@ def __init__(self, **kwargs: Any) -> None: self.description = None -class OperationImpact(_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.unit = None - self.change_value_absolute = None - self.change_value_relative = None - - class OperationListResult(_serialization.Model): """Result of the request to list SQL operations. @@ -14442,6 +15469,55 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: self.replication_role = None +class PerDatabaseAutoPauseDelayTimeRange(_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 if no value is provided. + :vartype default: int + :ivar unit: Unit of time that delay is expressed in. "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: Any) -> None: + """ """ + super().__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 PerformanceLevelCapability(_serialization.Model): """The performance level capability. @@ -14470,6 +15546,35 @@ def __init__(self, **kwargs: Any) -> None: self.unit = None +class PhaseDetails(_serialization.Model): + """The phase details properties of a database operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar phase: The operation phase. Known values are: "Copying", "Catchup", "WaitingForCutover", + and "CutoverInProgress". + :vartype phase: str or ~azure.mgmt.sql.models.Phase + :ivar phase_information: The operation phase information. + :vartype phase_information: dict[str, str] + """ + + _validation = { + "phase": {"readonly": True}, + "phase_information": {"readonly": True}, + } + + _attribute_map = { + "phase": {"key": "phase", "type": "str"}, + "phase_information": {"key": "phaseInformation", "type": "{str}"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.phase = None + self.phase_information = None + + class PrivateEndpointConnection(ProxyResource): """A private endpoint connection. @@ -14834,20 +15939,60 @@ class QueryCheck(_serialization.Model): } _attribute_map = { - "query": {"key": "query", "type": "str"}, - "expected_result": {"key": "expectedResult", "type": "[[str]]"}, - "column_names": {"key": "columnNames", "type": "[str]"}, + "query": {"key": "query", "type": "str"}, + "expected_result": {"key": "expectedResult", "type": "[[str]]"}, + "column_names": {"key": "columnNames", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.query = None + self.expected_result = None + self.column_names = None + + +class QueryMetricInterval(_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). Known values are: "PT1H" and "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: int + :ivar metrics: List of metric objects for this interval. + :vartype 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": "int"}, + "metrics": {"key": "metrics", "type": "[QueryMetricProperties]"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, metrics: Optional[List["_models.QueryMetricProperties"]] = None, **kwargs: Any) -> None: + """ + :keyword metrics: List of metric objects for this interval. + :paramtype metrics: list[~azure.mgmt.sql.models.QueryMetricProperties] + """ super().__init__(**kwargs) - self.query = None - self.expected_result = None - self.column_names = None + self.interval_start_time = None + self.interval_type = None + self.execution_count = None + self.metrics = metrics -class QueryMetricInterval(_serialization.Model): +class QueryMetricIntervalAutoGenerated(_serialization.Model): """Properties of a query metrics interval. Variables are only populated by the server, and will be ignored when sending a request. @@ -15022,7 +16167,7 @@ class QueryStatisticsProperties(_serialization.Model): :ivar end_time: The end time for the metric (ISO-8601 format). :vartype end_time: str :ivar intervals: List of intervals with appropriate metric data. - :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + :vartype intervals: list[~azure.mgmt.sql.models.QueryMetricIntervalAutoGenerated] """ _validation = { @@ -15037,13 +16182,15 @@ class QueryStatisticsProperties(_serialization.Model): "query_id": {"key": "queryId", "type": "str"}, "start_time": {"key": "startTime", "type": "str"}, "end_time": {"key": "endTime", "type": "str"}, - "intervals": {"key": "intervals", "type": "[QueryMetricInterval]"}, + "intervals": {"key": "intervals", "type": "[QueryMetricIntervalAutoGenerated]"}, } - def __init__(self, *, intervals: Optional[List["_models.QueryMetricInterval"]] = None, **kwargs: Any) -> None: + def __init__( + self, *, intervals: Optional[List["_models.QueryMetricIntervalAutoGenerated"]] = None, **kwargs: Any + ) -> None: """ :keyword intervals: List of intervals with appropriate metric data. - :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricInterval] + :paramtype intervals: list[~azure.mgmt.sql.models.QueryMetricIntervalAutoGenerated] """ super().__init__(**kwargs) self.database_name = None @@ -15126,13 +16273,13 @@ class RecommendedAction(ProxyResource): # pylint: disable=too-many-instance-att :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 + :vartype execute_action_duration: ~datetime.timedelta :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 + :vartype revert_action_duration: ~datetime.timedelta :ivar execute_action_initiated_by: Gets if approval for applying this recommended action was given by user/system. Known values are: "User" and "System". :vartype execute_action_initiated_by: str or @@ -15214,9 +16361,9 @@ class RecommendedAction(ProxyResource): # pylint: disable=too-many-instance-att "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"}, + "execute_action_duration": {"key": "properties.executeActionDuration", "type": "duration"}, "revert_action_start_time": {"key": "properties.revertActionStartTime", "type": "iso-8601"}, - "revert_action_duration": {"key": "properties.revertActionDuration", "type": "str"}, + "revert_action_duration": {"key": "properties.revertActionDuration", "type": "duration"}, "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"}, @@ -15784,6 +16931,66 @@ def __init__(self, **kwargs: Any) -> None: self.error_message = None +class RefreshExternalGovernanceStatusOperationResultMI(ProxyResource): + """An RefreshExternalGovernanceStatus 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 managed_instance_name: Managed instance name. + :vartype managed_instance_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}, + "queued_time": {"readonly": True}, + "managed_instance_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"}, + "queued_time": {"key": "properties.queuedTime", "type": "str"}, + "managed_instance_name": {"key": "properties.managedInstanceName", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "error_message": {"key": "properties.errorMessage", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.request_id = None + self.request_type = None + self.queued_time = None + self.managed_instance_name = None + self.status = None + self.error_message = None + + class Remediation(_serialization.Model): """SQL Vulnerability Assessment remediation Details. @@ -15837,6 +17044,8 @@ class ReplicationLink(ProxyResource): # pylint: disable=too-many-instance-attri :vartype partner_server: str :ivar partner_database: Resource partner database. :vartype partner_database: str + :ivar partner_database_id: Resource partner database Id. + :vartype partner_database_id: str :ivar partner_location: Resource partner location. :vartype partner_location: str :ivar role: Local replication role. Known values are: "Primary", "Secondary", @@ -15867,6 +17076,7 @@ class ReplicationLink(ProxyResource): # pylint: disable=too-many-instance-attri "type": {"readonly": True}, "partner_server": {"readonly": True}, "partner_database": {"readonly": True}, + "partner_database_id": {"readonly": True}, "partner_location": {"readonly": True}, "role": {"readonly": True}, "partner_role": {"readonly": True}, @@ -15884,6 +17094,7 @@ class ReplicationLink(ProxyResource): # pylint: disable=too-many-instance-attri "type": {"key": "type", "type": "str"}, "partner_server": {"key": "properties.partnerServer", "type": "str"}, "partner_database": {"key": "properties.partnerDatabase", "type": "str"}, + "partner_database_id": {"key": "properties.partnerDatabaseId", "type": "str"}, "partner_location": {"key": "properties.partnerLocation", "type": "str"}, "role": {"key": "properties.role", "type": "str"}, "partner_role": {"key": "properties.partnerRole", "type": "str"}, @@ -15900,6 +17111,7 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.partner_server = None self.partner_database = None + self.partner_database_id = None self.partner_location = None self.role = None self.partner_role = None @@ -16600,6 +17812,9 @@ class SensitivityLabel(ProxyResource): # pylint: disable=too-many-instance-attr :vartype is_disabled: bool :ivar rank: Known values are: "None", "Low", "Medium", "High", and "Critical". :vartype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank + :ivar client_classification_source: Known values are: "None", "Native", "Recommended", and + "MIP". + :vartype client_classification_source: str or ~azure.mgmt.sql.models.ClientClassificationSource """ _validation = { @@ -16627,6 +17842,7 @@ class SensitivityLabel(ProxyResource): # pylint: disable=too-many-instance-attr "information_type_id": {"key": "properties.informationTypeId", "type": "str"}, "is_disabled": {"key": "properties.isDisabled", "type": "bool"}, "rank": {"key": "properties.rank", "type": "str"}, + "client_classification_source": {"key": "properties.clientClassificationSource", "type": "str"}, } def __init__( @@ -16637,6 +17853,7 @@ def __init__( information_type: Optional[str] = None, information_type_id: Optional[str] = None, rank: Optional[Union[str, "_models.SensitivityLabelRank"]] = None, + client_classification_source: Optional[Union[str, "_models.ClientClassificationSource"]] = None, **kwargs: Any ) -> None: """ @@ -16650,6 +17867,10 @@ def __init__( :paramtype information_type_id: str :keyword rank: Known values are: "None", "Low", "Medium", "High", and "Critical". :paramtype rank: str or ~azure.mgmt.sql.models.SensitivityLabelRank + :keyword client_classification_source: Known values are: "None", "Native", "Recommended", and + "MIP". + :paramtype client_classification_source: str or + ~azure.mgmt.sql.models.ClientClassificationSource """ super().__init__(**kwargs) self.managed_by = None @@ -16662,6 +17883,7 @@ def __init__( self.information_type_id = information_type_id self.is_disabled = None self.rank = rank + self.client_classification_source = client_classification_source class SensitivityLabelListResult(_serialization.Model): @@ -16843,6 +18065,10 @@ class Server(TrackedResource): # pylint: disable=too-many-instance-attributes are: "Enabled" and "Disabled". :vartype restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :ivar is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag :ivar external_governance_status: Status of external governance. Known values are: "Enabled" and "Disabled". :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus @@ -16886,6 +18112,7 @@ class Server(TrackedResource): # pylint: disable=too-many-instance-attributes "key_id": {"key": "properties.keyId", "type": "str"}, "administrators": {"key": "properties.administrators", "type": "ServerExternalAdministrator"}, "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, + "is_i_pv6_enabled": {"key": "properties.isIPv6Enabled", "type": "str"}, "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, } @@ -16905,6 +18132,7 @@ def __init__( key_id: Optional[str] = None, administrators: Optional["_models.ServerExternalAdministrator"] = None, restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, + is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, **kwargs: Any ) -> None: """ @@ -16944,6 +18172,10 @@ def __init__( values are: "Enabled" and "Disabled". :paramtype restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :keyword is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :paramtype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag """ super().__init__(location=location, tags=tags, **kwargs) self.identity = identity @@ -16962,6 +18194,7 @@ def __init__( self.key_id = key_id self.administrators = administrators self.restrict_outbound_network_access = restrict_outbound_network_access + self.is_i_pv6_enabled = is_i_pv6_enabled self.external_governance_status = None @@ -17559,78 +18792,6 @@ def __init__(self, **kwargs: Any) -> 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 - :ivar partner_server: The name of the partner server. - :vartype 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, *, partner_server: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword partner_server: The name of the partner server. - :paramtype partner_server: str - """ - super().__init__(**kwargs) - self.location = None - self.kind = None - self.state = None - self.partner_server = partner_server - - -class ServerCommunicationLinkListResult(_serialization.Model): - """A list of server communication links. - - :ivar value: The list of server communication links. - :vartype value: list[~azure.mgmt.sql.models.ServerCommunicationLink] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ServerCommunicationLink]"}, - } - - def __init__(self, *, value: Optional[List["_models.ServerCommunicationLink"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of server communication links. - :paramtype value: list[~azure.mgmt.sql.models.ServerCommunicationLink] - """ - super().__init__(**kwargs) - self.value = value - - class ServerConfigurationOption(ProxyResource): """A server configuration option. @@ -18151,7 +19312,8 @@ class ServerKey(ProxyResource): # pylint: disable=too-many-instance-attributes are: "ServiceManaged" and "AzureKeyVault". :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. + required. The AKV URI is required to be in this format: + 'https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion'. :vartype uri: str :ivar thumbprint: Thumbprint of the server key. :vartype thumbprint: str @@ -18199,7 +19361,8 @@ def __init__( values are: "ServiceManaged" and "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. + required. The AKV URI is required to be in this format: + 'https://YourVaultName.vault.azure.net/keys/YourKeyName/YourKeyVersion'. :paramtype uri: str """ super().__init__(**kwargs) @@ -18733,6 +19896,10 @@ class ServerUpdate(_serialization.Model): # pylint: disable=too-many-instance-a are: "Enabled" and "Disabled". :vartype restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :ivar is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag :ivar external_governance_status: Status of external governance. Known values are: "Enabled" and "Disabled". :vartype external_governance_status: str or ~azure.mgmt.sql.models.ExternalGovernanceStatus @@ -18766,6 +19933,7 @@ class ServerUpdate(_serialization.Model): # pylint: disable=too-many-instance-a "key_id": {"key": "properties.keyId", "type": "str"}, "administrators": {"key": "properties.administrators", "type": "ServerExternalAdministrator"}, "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, + "is_i_pv6_enabled": {"key": "properties.isIPv6Enabled", "type": "str"}, "external_governance_status": {"key": "properties.externalGovernanceStatus", "type": "str"}, } @@ -18784,6 +19952,7 @@ def __init__( key_id: Optional[str] = None, administrators: Optional["_models.ServerExternalAdministrator"] = None, restrict_outbound_network_access: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, + is_i_pv6_enabled: Optional[Union[str, "_models.ServerNetworkAccessFlag"]] = None, **kwargs: Any ) -> None: """ @@ -18821,6 +19990,10 @@ def __init__( values are: "Enabled" and "Disabled". :paramtype restrict_outbound_network_access: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag + :keyword is_i_pv6_enabled: Whether or not to enable IPv6 support for this server. Value is + optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :paramtype is_i_pv6_enabled: str or ~azure.mgmt.sql.models.ServerNetworkAccessFlag """ super().__init__(**kwargs) self.identity = identity @@ -18839,86 +20012,86 @@ def __init__( self.key_id = key_id self.administrators = administrators self.restrict_outbound_network_access = restrict_outbound_network_access + self.is_i_pv6_enabled = is_i_pv6_enabled self.external_governance_status = None -class ServerUsage(_serialization.Model): - """Represents server metrics. +class ServerUsage(ProxyResource): + """Usage metric of a server. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Name of the server usage metric. + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. :vartype name: str - :ivar resource_name: The name of the resource. - :vartype resource_name: str - :ivar display_name: The metric display name. + :ivar type: Resource type. + :vartype type: str + :ivar display_name: User-readable name of the metric. :vartype display_name: str - :ivar current_value: The current value of the metric. + :ivar current_value: Current value of the metric. :vartype current_value: float - :ivar limit: The current limit of the metric. + :ivar limit: Boundary value of the metric. :vartype limit: float - :ivar unit: The units of the metric. + :ivar unit: Unit 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 = { + "id": {"readonly": True}, "name": {"readonly": True}, - "resource_name": {"readonly": True}, + "type": {"readonly": True}, "display_name": {"readonly": True}, "current_value": {"readonly": True}, "limit": {"readonly": True}, "unit": {"readonly": True}, - "next_reset_time": {"readonly": True}, } _attribute_map = { + "id": {"key": "id", "type": "str"}, "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"}, + "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: Any) -> None: """ """ super().__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(_serialization.Model): - """Represents the response to a list server metrics request. + """A list of server usage metrics. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of server metrics for the server. Required. + :ivar value: Array of results. :vartype value: list[~azure.mgmt.sql.models.ServerUsage] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str """ _validation = { - "value": {"required": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[ServerUsage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.ServerUsage"], **kwargs: Any) -> None: - """ - :keyword value: The list of server metrics for the server. Required. - :paramtype value: list[~azure.mgmt.sql.models.ServerUsage] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value + self.value = None + self.next_link = None class ServerVersionCapability(_serialization.Model): @@ -19081,61 +20254,6 @@ def __init__(self, **kwargs: Any) -> 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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.service_objective_name = None - self.is_default = None - self.is_system = None - self.description = None - self.enabled = None - - class ServiceObjectiveCapability(_serialization.Model): # pylint: disable=too-many-instance-attributes """The service objectives capability. @@ -19166,6 +20284,12 @@ class ServiceObjectiveCapability(_serialization.Model): # pylint: disable=too-m :ivar supported_maintenance_configurations: List of supported maintenance configurations. :vartype supported_maintenance_configurations: list[~azure.mgmt.sql.models.MaintenanceConfigurationCapability] + :ivar zone_pinning: Whether or not zone pinning is supported. + :vartype zone_pinning: bool + :ivar supported_free_limit_exhaustion_behaviors: List of supported free limit exhaustion + behaviors. + :vartype supported_free_limit_exhaustion_behaviors: + list[~azure.mgmt.sql.models.FreeLimitExhaustionBehaviorCapability] :ivar status: The status of the capability. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -19186,6 +20310,8 @@ class ServiceObjectiveCapability(_serialization.Model): # pylint: disable=too-m "supported_min_capacities": {"readonly": True}, "compute_model": {"readonly": True}, "supported_maintenance_configurations": {"readonly": True}, + "zone_pinning": {"readonly": True}, + "supported_free_limit_exhaustion_behaviors": {"readonly": True}, "status": {"readonly": True}, } @@ -19205,6 +20331,11 @@ class ServiceObjectiveCapability(_serialization.Model): # pylint: disable=too-m "key": "supportedMaintenanceConfigurations", "type": "[MaintenanceConfigurationCapability]", }, + "zone_pinning": {"key": "zonePinning", "type": "bool"}, + "supported_free_limit_exhaustion_behaviors": { + "key": "supportedFreeLimitExhaustionBehaviors", + "type": "[FreeLimitExhaustionBehaviorCapability]", + }, "status": {"key": "status", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } @@ -19227,36 +20358,12 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.supported_min_capacities = None self.compute_model = None self.supported_maintenance_configurations = None + self.zone_pinning = None + self.supported_free_limit_exhaustion_behaviors = None self.status = None self.reason = reason -class ServiceObjectiveListResult(_serialization.Model): - """Represents the response to a get database service objectives request. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The list of database service objectives. Required. - :vartype value: list[~azure.mgmt.sql.models.ServiceObjective] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ServiceObjective]"}, - } - - def __init__(self, *, value: List["_models.ServiceObjective"], **kwargs: Any) -> None: - """ - :keyword value: The list of database service objectives. Required. - :paramtype value: list[~azure.mgmt.sql.models.ServiceObjective] - """ - super().__init__(**kwargs) - self.value = value - - class ServicePrincipal(_serialization.Model): """The managed instance's service principal configuration for a resource. @@ -19358,46 +20465,6 @@ def __init__( self.capacity = capacity -class SloUsageMetric(_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. Known values - are: "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", and "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: Any) -> None: - """ """ - super().__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. @@ -19901,7 +20968,7 @@ class StorageCapability(_serialization.Model): 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. Known values - are: "GRS", "LRS", and "ZRS". + are: "GRS", "LRS", "ZRS", and "GZRS". :vartype storage_account_type: str or ~azure.mgmt.sql.models.StorageCapabilityStorageAccountType :ivar status: The status of the capability. Known values are: "Visible", "Available", @@ -21117,7 +22184,7 @@ def __init__( class TimeZone(ProxyResource): - """Time Zone. + """Time Zone property. Variables are only populated by the server, and will be ignored when sending a request. @@ -21378,19 +22445,28 @@ def __init__( self.storage_size_in_gb = storage_size_in_gb -class UpsertManagedServerOperationStep(_serialization.Model): - """UpsertManagedServerOperationStep. +class UpsertManagedServerOperationStepWithEstimatesAndDuration(_serialization.Model): + """UpsertManagedServerOperationStepWithEstimatesAndDuration. + :ivar step_start_time: + :vartype step_start_time: ~datetime.datetime + :ivar step_end_time: + :vartype step_end_time: ~datetime.datetime + :ivar time_elapsed: + :vartype time_elapsed: str :ivar order: :vartype order: int :ivar name: :vartype name: str :ivar status: Known values are: "NotStarted", "InProgress", "SlowedDown", "Completed", "Failed", and "Canceled". - :vartype status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus + :vartype status: str or ~azure.mgmt.sql.models.Status """ _attribute_map = { + "step_start_time": {"key": "stepStartTime", "type": "iso-8601"}, + "step_end_time": {"key": "stepEndTime", "type": "iso-8601"}, + "time_elapsed": {"key": "timeElapsed", "type": "str"}, "order": {"key": "order", "type": "int"}, "name": {"key": "name", "type": "str"}, "status": {"key": "status", "type": "str"}, @@ -21399,21 +22475,33 @@ class UpsertManagedServerOperationStep(_serialization.Model): def __init__( self, *, + step_start_time: Optional[datetime.datetime] = None, + step_end_time: Optional[datetime.datetime] = None, + time_elapsed: Optional[str] = None, order: Optional[int] = None, name: Optional[str] = None, - status: Optional[Union[str, "_models.UpsertManagedServerOperationStepStatus"]] = None, + status: Optional[Union[str, "_models.Status"]] = None, **kwargs: Any ) -> None: """ + :keyword step_start_time: + :paramtype step_start_time: ~datetime.datetime + :keyword step_end_time: + :paramtype step_end_time: ~datetime.datetime + :keyword time_elapsed: + :paramtype time_elapsed: str :keyword order: :paramtype order: int :keyword name: :paramtype name: str :keyword status: Known values are: "NotStarted", "InProgress", "SlowedDown", "Completed", "Failed", and "Canceled". - :paramtype status: str or ~azure.mgmt.sql.models.UpsertManagedServerOperationStepStatus + :paramtype status: str or ~azure.mgmt.sql.models.Status """ super().__init__(**kwargs) + self.step_start_time = step_start_time + self.step_end_time = step_end_time + self.time_elapsed = time_elapsed self.order = order self.name = name self.status = status 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 c2076d7651bf..6782be9bac2d 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 @@ -60,7 +60,7 @@ class AggregationFunctionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AlwaysEncryptedEnclaveType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of enclave requested on the elastic pool.""" + """Type of enclave requested on the database i.e. Default or VBS enclaves.""" DEFAULT = "Default" VBS = "VBS" @@ -72,6 +72,14 @@ class AuthenticationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" +class AuthMetadataLookupModes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed instance's authentication metadata lookup mode.""" + + AZURE_AD = "AzureAD" + PAIRED = "Paired" + WINDOWS = "Windows" + + class AutoExecuteStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the auto-execute status (whether to let the system execute the recommendations) of this advisor. Possible values are 'Enabled' and 'Disabled'. @@ -149,7 +157,7 @@ class AutomaticTuningServerReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): class AvailabilityZoneType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the availability zone the pool's primary replica is pinned to.""" + """Specifies the availability zone the database is pinned to.""" NO_PREFERENCE = "NoPreference" ONE = "1" @@ -157,8 +165,15 @@ class AvailabilityZoneType(str, Enum, metaclass=CaseInsensitiveEnumMeta): THREE = "3" +class BackupStorageAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The BackupStorageAccessTier for the LTR backup.""" + + HOT = "Hot" + ARCHIVE = "Archive" + + class BackupStorageRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The storage redundancy type of the copied backup.""" + """The storage account type used to store backups for this database.""" GEO = "Geo" LOCAL = "Local" @@ -189,6 +204,7 @@ class CapabilityGroup(str, Enum, metaclass=CaseInsensitiveEnumMeta): SUPPORTED_MANAGED_INSTANCE_VERSIONS = "supportedManagedInstanceVersions" SUPPORTED_INSTANCE_POOL_EDITIONS = "supportedInstancePoolEditions" SUPPORTED_MANAGED_INSTANCE_EDITIONS = "supportedManagedInstanceEditions" + SUPPORTED_JOB_AGENT_VERSIONS = "supportedJobAgentVersions" class CapabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -216,6 +232,15 @@ class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ALREADY_EXISTS = "AlreadyExists" +class ClientClassificationSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ClientClassificationSource.""" + + NONE = "None" + NATIVE = "Native" + RECOMMENDED = "Recommended" + MIP = "MIP" + + class ColumnDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The column data type.""" @@ -394,6 +419,12 @@ class DataMaskingFunction(str, Enum, metaclass=CaseInsensitiveEnumMeta): TEXT = "Text" +class DataMaskingPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataMaskingPolicyName.""" + + DEFAULT = "Default" + + class DataMaskingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 @@ -401,15 +432,15 @@ class DataMaskingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): the provided value of ruleState. """ - DISABLED = "Disabled" ENABLED = "Enabled" + DISABLED = "Disabled" class DataMaskingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the data masking policy.""" - DISABLED = "Disabled" ENABLED = "Enabled" + DISABLED = "Disabled" class DataWarehouseUserActivityName(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -495,6 +526,15 @@ class FailoverGroupReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta) SECONDARY = "Secondary" +class FailoverModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The link failover mode - can be Manual if intended to be used for two-way failover with a + supported SQL Server, or None for one-way failover to Azure. + """ + + NONE = "None" + MANUAL = "Manual" + + class FreeLimitExhaustionBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior when monthly free limits are exhausted for the free database. @@ -509,6 +549,13 @@ class FreeLimitExhaustionBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): BILL_OVER_USAGE = "BillOverUsage" +class FreemiumType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Weather or not Managed Instance is freemium.""" + + REGULAR = "Regular" + FREEMIUM = "Freemium" + + class GeoBackupPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """GeoBackupPolicyName.""" @@ -518,8 +565,27 @@ class GeoBackupPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): class GeoBackupPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the geo backup policy.""" - DISABLED = "Disabled" ENABLED = "Enabled" + DISABLED = "Disabled" + + +class HybridSecondaryUsage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Hybrid secondary usage. Possible values are 'Active' (default value) and 'Passive' (customer + uses the secondary as Passive DR). + """ + + ACTIVE = "Active" + PASSIVE = "Passive" + + +class HybridSecondaryUsageDetected(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Hybrid secondary usage detected. Possible values are 'Active' (customer does not meet the + requirements to use the secondary as Passive DR) and 'Passive' (customer meets the requirements + to use the secondary as Passive DR). + """ + + ACTIVE = "Active" + PASSIVE = "Passive" class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -558,6 +624,13 @@ class InstancePoolLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BASE_PRICE = "BasePrice" +class InstanceRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """New role of managed instance in a distributed availability group, can be Primary or Secondary.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + class IsRetryable(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets whether the error could be ignored and recommended action could be retried. Possible values are: Yes/No. @@ -567,6 +640,15 @@ class IsRetryable(str, Enum, metaclass=CaseInsensitiveEnumMeta): NO = "No" +class JobAgentIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The job agent identity type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssignedUserAssigned" + + class JobAgentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the job agent.""" @@ -647,6 +729,13 @@ class LedgerDigestUploadsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class LinkRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SQL server side link role.""" + + PRIMARY = "Primary" + SECONDARY = "Secondary" + + class LogSizeUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The units that the limit is expressed in.""" @@ -704,6 +793,13 @@ class ManagedInstanceAdministratorType(str, Enum, metaclass=CaseInsensitiveEnumM ACTIVE_DIRECTORY = "ActiveDirectory" +class ManagedInstanceDatabaseFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the internal format of instance databases specific to the SQL engine version.""" + + ALWAYS_UP_TO_DATE = "AlwaysUpToDate" + SQL_SERVER2022 = "SQLServer2022" + + class ManagedInstanceLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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). @@ -719,26 +815,6 @@ class ManagedInstanceLongTermRetentionPolicyName(str, Enum, metaclass=CaseInsens DEFAULT = "default" -class ManagedInstancePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ManagedInstancePropertiesProvisioningState.""" - - CREATING = "Creating" - DELETING = "Deleting" - UPDATING = "Updating" - UNKNOWN = "Unknown" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - ACCEPTED = "Accepted" - CREATED = "Created" - DELETED = "Deleted" - UNRECOGNIZED = "Unrecognized" - RUNNING = "Running" - CANCELED = "Canceled" - NOT_SPECIFIED = "NotSpecified" - REGISTERING = "Registering" - TIMED_OUT = "TimedOut" - - class ManagedInstanceProxyOverride(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Connection type used for connecting to the instance.""" @@ -817,9 +893,12 @@ class MoveOperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): class OperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Operation Mode.""" + """Operation mode of the operation: Import, Export, or PolybaseImport.""" POLYBASE_IMPORT = "PolybaseImport" + IMPORT = "Import" + EXPORT = "Export" + IMPORT_ENUM = "Import" class OperationOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -842,15 +921,13 @@ class PerformanceLevelUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): V_CORES = "VCores" -class PrimaryAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The primary aggregation type defining how metric values are displayed.""" +class Phase(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation phase.""" - NONE = "None" - AVERAGE = "Average" - COUNT = "Count" - MINIMUM = "Minimum" - MAXIMUM = "Maximum" - TOTAL = "Total" + COPYING = "Copying" + CATCHUP = "Catchup" + WAITING_FOR_CUTOVER = "WaitingForCutover" + CUTOVER_IN_PROGRESS = "CutoverInProgress" class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -971,6 +1048,21 @@ class RecommendedSensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitive DISABLE = "disable" +class ReplicaConnectedState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Link connected state.""" + + DISCONNECTED = "DISCONNECTED" + CONNECTED = "CONNECTED" + + +class ReplicaSynchronizationHealth(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Link health state.""" + + NOT_HEALTHY = "NOT_HEALTHY" + PARTIALLY_HEALTHY = "PARTIALLY_HEALTHY" + HEALTHY = "HEALTHY" + + class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Link type (GEO, NAMED, STANDBY).""" @@ -979,10 +1071,8 @@ class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDBY = "STANDBY" -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The replication mode of a distributed availability group. Parameter will be ignored during link - creation. - """ +class ReplicationModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Replication mode of the link.""" ASYNC = "Async" SYNC = "Sync" @@ -1028,6 +1118,13 @@ class RestorePointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISCRETE = "DISCRETE" +class RoleChangeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the role change, can be Planned or Forced.""" + + FORCED = "Forced" + PLANNED = "Planned" + + class RuleSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SQL Vulnerability Assessment rule severity.""" @@ -1083,6 +1180,12 @@ class SecondaryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SecurityAlertPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SecurityAlertPolicyName.""" + DEFAULT = "default" + + +class SecurityAlertPolicyNameAutoGenerated(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SecurityAlertPolicyNameAutoGenerated.""" + DEFAULT = "Default" @@ -1113,6 +1216,13 @@ class SecurityEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SQL_INJECTION_EXPLOIT = "SqlInjectionExploit" +class SeedingModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database seeding mode – can be Automatic (default), or Manual for supported scenarios.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + + class SensitivityLabelRank(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SensitivityLabelRank.""" @@ -1193,76 +1303,6 @@ class ServerWorkspaceFeature(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISCONNECTED = "Disconnected" -class ServiceObjectiveName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The serviceLevelObjective for SLO usage metric.""" - - SYSTEM = "System" - SYSTEM0 = "System0" - SYSTEM1 = "System1" - SYSTEM2 = "System2" - SYSTEM3 = "System3" - SYSTEM4 = "System4" - SYSTEM2_L = "System2L" - SYSTEM3_L = "System3L" - SYSTEM4_L = "System4L" - FREE = "Free" - BASIC = "Basic" - S0 = "S0" - S1 = "S1" - S2 = "S2" - S3 = "S3" - S4 = "S4" - S6 = "S6" - S7 = "S7" - S9 = "S9" - S12 = "S12" - P1 = "P1" - P2 = "P2" - P3 = "P3" - P4 = "P4" - P6 = "P6" - P11 = "P11" - P15 = "P15" - PRS1 = "PRS1" - PRS2 = "PRS2" - PRS4 = "PRS4" - PRS6 = "PRS6" - DW100 = "DW100" - DW200 = "DW200" - DW300 = "DW300" - DW400 = "DW400" - DW500 = "DW500" - DW600 = "DW600" - DW1000 = "DW1000" - DW1200 = "DW1200" - DW1000_C = "DW1000c" - DW1500 = "DW1500" - DW1500_C = "DW1500c" - DW2000 = "DW2000" - DW2000_C = "DW2000c" - DW3000 = "DW3000" - DW2500_C = "DW2500c" - DW3000_C = "DW3000c" - DW6000 = "DW6000" - DW5000_C = "DW5000c" - DW6000_C = "DW6000c" - DW7500_C = "DW7500c" - DW10000_C = "DW10000c" - DW15000_C = "DW15000c" - DW30000_C = "DW30000c" - DS100 = "DS100" - DS200 = "DS200" - DS300 = "DS300" - DS400 = "DS400" - DS500 = "DS500" - DS600 = "DS600" - DS1000 = "DS1000" - DS1200 = "DS1200" - DS1500 = "DS1500" - DS2000 = "DS2000" - ELASTIC_POOL = "ElasticPool" - - class ServicePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Service principal type.""" @@ -1304,16 +1344,28 @@ class StartStopScheduleName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status.""" + + NOT_STARTED = "NotStarted" + IN_PROGRESS = "InProgress" + SLOWED_DOWN = "SlowedDown" + COMPLETED = "Completed" + FAILED = "Failed" + CANCELED = "Canceled" + + class StorageCapabilityStorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The storage account type for the database's backups.""" GRS = "GRS" LRS = "LRS" ZRS = "ZRS" + GZRS = "GZRS" class StorageKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Storage key type.""" + """Storage key type: StorageAccessKey or SharedAccessKey.""" SHARED_ACCESS_KEY = "SharedAccessKey" STORAGE_ACCESS_KEY = "StorageAccessKey" @@ -1421,39 +1473,6 @@ class TransparentDataEncryptionState(str, Enum, metaclass=CaseInsensitiveEnumMet DISABLED = "Disabled" -class UnitDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "Count" - BYTES = "Bytes" - SECONDS = "Seconds" - PERCENT = "Percent" - COUNT_PER_SECOND = "CountPerSecond" - BYTES_PER_SECOND = "BytesPerSecond" - - -class UnitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric.""" - - COUNT = "count" - BYTES = "bytes" - SECONDS = "seconds" - PERCENT = "percent" - COUNT_PER_SECOND = "countPerSecond" - BYTES_PER_SECOND = "bytesPerSecond" - - -class UpsertManagedServerOperationStepStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UpsertManagedServerOperationStepStatus.""" - - NOT_STARTED = "NotStarted" - IN_PROGRESS = "InProgress" - SLOWED_DOWN = "SlowedDown" - COMPLETED = "Completed" - FAILED = "Failed" - CANCELED = "Canceled" - - class VirtualNetworkRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Virtual Network Rule State.""" 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 b4dafd81fe63..810288a09bc3 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 @@ -6,66 +6,110 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations +from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations +from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations +from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations +from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations from ._data_masking_policies_operations import DataMaskingPoliciesOperations from ._data_masking_rules_operations import DataMaskingRulesOperations -from ._geo_backup_policies_operations import GeoBackupPoliciesOperations -from ._databases_operations import DatabasesOperations -from ._elastic_pools_operations import ElasticPoolsOperations -from ._server_communication_links_operations import ServerCommunicationLinksOperations -from ._service_objectives_operations import ServiceObjectivesOperations -from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations -from ._elastic_pool_database_activities_operations import ElasticPoolDatabaseActivitiesOperations -from ._server_usages_operations import ServerUsagesOperations +from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations +from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations from ._database_advisors_operations import DatabaseAdvisorsOperations from ._database_automatic_tuning_operations import DatabaseAutomaticTuningOperations from ._database_columns_operations import DatabaseColumnsOperations +from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations +from ._database_extensions_operations import DatabaseExtensionsOperations +from ._database_operations_operations import DatabaseOperationsOperations from ._database_recommended_actions_operations import DatabaseRecommendedActionsOperations from ._database_schemas_operations import DatabaseSchemasOperations from ._database_security_alert_policies_operations import DatabaseSecurityAlertPoliciesOperations +from ._database_sql_vulnerability_assessment_baselines_operations import ( + DatabaseSqlVulnerabilityAssessmentBaselinesOperations, +) +from ._database_sql_vulnerability_assessment_execute_scan_operations import ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations, +) +from ._database_sql_vulnerability_assessment_rule_baselines_operations import ( + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations, +) +from ._database_sql_vulnerability_assessment_scan_result_operations import ( + DatabaseSqlVulnerabilityAssessmentScanResultOperations, +) +from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations +from ._database_sql_vulnerability_assessments_settings_operations import ( + DatabaseSqlVulnerabilityAssessmentsSettingsOperations, +) from ._database_tables_operations import DatabaseTablesOperations +from ._database_usages_operations import DatabaseUsagesOperations from ._database_vulnerability_assessment_rule_baselines_operations import ( DatabaseVulnerabilityAssessmentRuleBaselinesOperations, ) -from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations from ._database_vulnerability_assessment_scans_operations import DatabaseVulnerabilityAssessmentScansOperations -from ._data_warehouse_user_activities_operations import DataWarehouseUserActivitiesOperations +from ._database_vulnerability_assessments_operations import DatabaseVulnerabilityAssessmentsOperations +from ._databases_operations import DatabasesOperations from ._deleted_servers_operations import DeletedServersOperations +from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations from ._elastic_pool_operations_operations import ElasticPoolOperationsOperations +from ._elastic_pools_operations import ElasticPoolsOperations from ._encryption_protectors_operations import EncryptionProtectorsOperations +from ._endpoint_certificates_operations import EndpointCertificatesOperations +from ._failover_groups_operations import FailoverGroupsOperations from ._firewall_rules_operations import FirewallRulesOperations +from ._geo_backup_policies_operations import GeoBackupPoliciesOperations +from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations +from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations from ._instance_pools_operations import InstancePoolsOperations from ._job_agents_operations import JobAgentsOperations from ._job_credentials_operations import JobCredentialsOperations from ._job_executions_operations import JobExecutionsOperations -from ._jobs_operations import JobsOperations +from ._job_private_endpoints_operations import JobPrivateEndpointsOperations from ._job_step_executions_operations import JobStepExecutionsOperations from ._job_steps_operations import JobStepsOperations from ._job_target_executions_operations import JobTargetExecutionsOperations from ._job_target_groups_operations import JobTargetGroupsOperations from ._job_versions_operations import JobVersionsOperations +from ._jobs_operations import JobsOperations +from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations from ._capabilities_operations import CapabilitiesOperations +from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations +from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations from ._long_term_retention_policies_operations import LongTermRetentionPoliciesOperations from ._maintenance_window_options_operations import MaintenanceWindowOptionsOperations from ._maintenance_windows_operations import MaintenanceWindowsOperations from ._managed_backup_short_term_retention_policies_operations import ManagedBackupShortTermRetentionPoliciesOperations +from ._managed_database_advanced_threat_protection_settings_operations import ( + ManagedDatabaseAdvancedThreatProtectionSettingsOperations, +) from ._managed_database_columns_operations import ManagedDatabaseColumnsOperations +from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations from ._managed_database_queries_operations import ManagedDatabaseQueriesOperations +from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations from ._managed_database_schemas_operations import ManagedDatabaseSchemasOperations from ._managed_database_security_alert_policies_operations import ManagedDatabaseSecurityAlertPoliciesOperations from ._managed_database_security_events_operations import ManagedDatabaseSecurityEventsOperations +from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations +from ._managed_database_recommended_sensitivity_labels_operations import ( + ManagedDatabaseRecommendedSensitivityLabelsOperations, +) from ._managed_database_tables_operations import ManagedDatabaseTablesOperations from ._managed_database_transparent_data_encryption_operations import ManagedDatabaseTransparentDataEncryptionOperations from ._managed_database_vulnerability_assessment_rule_baselines_operations import ( ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations, ) -from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations from ._managed_database_vulnerability_assessment_scans_operations import ( ManagedDatabaseVulnerabilityAssessmentScansOperations, ) +from ._managed_database_vulnerability_assessments_operations import ManagedDatabaseVulnerabilityAssessmentsOperations +from ._managed_databases_operations import ManagedDatabasesOperations from ._managed_instance_administrators_operations import ManagedInstanceAdministratorsOperations +from ._managed_instance_advanced_threat_protection_settings_operations import ( + ManagedInstanceAdvancedThreatProtectionSettingsOperations, +) from ._managed_instance_azure_ad_only_authentications_operations import ( ManagedInstanceAzureADOnlyAuthenticationsOperations, ) +from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations from ._managed_instance_encryption_protectors_operations import ManagedInstanceEncryptionProtectorsOperations from ._managed_instance_keys_operations import ManagedInstanceKeysOperations from ._managed_instance_long_term_retention_policies_operations import ( @@ -78,88 +122,44 @@ from ._managed_instance_private_link_resources_operations import ManagedInstancePrivateLinkResourcesOperations from ._managed_instance_tde_certificates_operations import ManagedInstanceTdeCertificatesOperations from ._managed_instance_vulnerability_assessments_operations import ManagedInstanceVulnerabilityAssessmentsOperations +from ._managed_instances_operations import ManagedInstancesOperations +from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations from ._managed_restorable_dropped_database_backup_short_term_retention_policies_operations import ( ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ) +from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations from ._managed_server_security_alert_policies_operations import ManagedServerSecurityAlertPoliciesOperations +from ._network_security_perimeter_configurations_operations import NetworkSecurityPerimeterConfigurationsOperations from ._operations import Operations +from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._recoverable_databases_operations import RecoverableDatabasesOperations from ._recoverable_managed_databases_operations import RecoverableManagedDatabasesOperations +from ._replication_links_operations import ReplicationLinksOperations +from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations +from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations from ._restore_points_operations import RestorePointsOperations +from ._sensitivity_labels_operations import SensitivityLabelsOperations +from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations +from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations from ._server_advisors_operations import ServerAdvisorsOperations from ._server_automatic_tuning_operations import ServerAutomaticTuningOperations from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations +from ._server_configuration_options_operations import ServerConfigurationOptionsOperations +from ._server_connection_policies_operations import ServerConnectionPoliciesOperations from ._server_dev_ops_audit_settings_operations import ServerDevOpsAuditSettingsOperations from ._server_dns_aliases_operations import ServerDnsAliasesOperations from ._server_keys_operations import ServerKeysOperations from ._server_operations_operations import ServerOperationsOperations from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations +from ._server_trust_certificates_operations import ServerTrustCertificatesOperations from ._server_trust_groups_operations import ServerTrustGroupsOperations +from ._server_usages_operations import ServerUsagesOperations from ._server_vulnerability_assessments_operations import ServerVulnerabilityAssessmentsOperations -from ._sql_agent_operations import SqlAgentOperations -from ._subscription_usages_operations import SubscriptionUsagesOperations -from ._sync_agents_operations import SyncAgentsOperations -from ._sync_groups_operations import SyncGroupsOperations -from ._sync_members_operations import SyncMembersOperations -from ._tde_certificates_operations import TdeCertificatesOperations -from ._time_zones_operations import TimeZonesOperations -from ._virtual_network_rules_operations import VirtualNetworkRulesOperations -from ._workload_classifiers_operations import WorkloadClassifiersOperations -from ._workload_groups_operations import WorkloadGroupsOperations -from ._backup_short_term_retention_policies_operations import BackupShortTermRetentionPoliciesOperations -from ._database_extensions_operations import DatabaseExtensionsOperations -from ._database_operations_operations import DatabaseOperationsOperations -from ._database_usages_operations import DatabaseUsagesOperations -from ._ledger_digest_uploads_operations import LedgerDigestUploadsOperations -from ._outbound_firewall_rules_operations import OutboundFirewallRulesOperations -from ._usages_operations import UsagesOperations -from ._long_term_retention_backups_operations import LongTermRetentionBackupsOperations -from ._long_term_retention_managed_instance_backups_operations import LongTermRetentionManagedInstanceBackupsOperations -from ._restorable_dropped_managed_databases_operations import RestorableDroppedManagedDatabasesOperations -from ._server_connection_policies_operations import ServerConnectionPoliciesOperations -from ._distributed_availability_groups_operations import DistributedAvailabilityGroupsOperations -from ._server_trust_certificates_operations import ServerTrustCertificatesOperations -from ._endpoint_certificates_operations import EndpointCertificatesOperations -from ._managed_database_sensitivity_labels_operations import ManagedDatabaseSensitivityLabelsOperations -from ._managed_database_recommended_sensitivity_labels_operations import ( - ManagedDatabaseRecommendedSensitivityLabelsOperations, -) -from ._sensitivity_labels_operations import SensitivityLabelsOperations -from ._recommended_sensitivity_labels_operations import RecommendedSensitivityLabelsOperations -from ._server_blob_auditing_policies_operations import ServerBlobAuditingPoliciesOperations -from ._database_blob_auditing_policies_operations import DatabaseBlobAuditingPoliciesOperations -from ._extended_database_blob_auditing_policies_operations import ExtendedDatabaseBlobAuditingPoliciesOperations -from ._extended_server_blob_auditing_policies_operations import ExtendedServerBlobAuditingPoliciesOperations -from ._database_advanced_threat_protection_settings_operations import DatabaseAdvancedThreatProtectionSettingsOperations -from ._server_advanced_threat_protection_settings_operations import ServerAdvancedThreatProtectionSettingsOperations -from ._managed_server_dns_aliases_operations import ManagedServerDnsAliasesOperations -from ._managed_database_advanced_threat_protection_settings_operations import ( - ManagedDatabaseAdvancedThreatProtectionSettingsOperations, -) -from ._managed_instance_advanced_threat_protection_settings_operations import ( - ManagedInstanceAdvancedThreatProtectionSettingsOperations, -) -from ._replication_links_operations import ReplicationLinksOperations -from ._managed_database_move_operations_operations import ManagedDatabaseMoveOperationsOperations -from ._managed_instance_dtcs_operations import ManagedInstanceDtcsOperations -from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations -from ._virtual_clusters_operations import VirtualClustersOperations -from ._instance_failover_groups_operations import InstanceFailoverGroupsOperations -from ._managed_database_restore_details_operations import ManagedDatabaseRestoreDetailsOperations -from ._database_encryption_protectors_operations import DatabaseEncryptionProtectorsOperations -from ._managed_databases_operations import ManagedDatabasesOperations -from ._managed_instances_operations import ManagedInstancesOperations -from ._managed_ledger_digest_uploads_operations import ManagedLedgerDigestUploadsOperations -from ._recoverable_databases_operations import RecoverableDatabasesOperations -from ._restorable_dropped_databases_operations import RestorableDroppedDatabasesOperations -from ._server_configuration_options_operations import ServerConfigurationOptionsOperations from ._servers_operations import ServersOperations -from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations -from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations -from ._failover_groups_operations import FailoverGroupsOperations -from ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations +from ._sql_agent_operations import SqlAgentOperations from ._sql_vulnerability_assessment_baseline_operations import SqlVulnerabilityAssessmentBaselineOperations from ._sql_vulnerability_assessment_baselines_operations import SqlVulnerabilityAssessmentBaselinesOperations from ._sql_vulnerability_assessment_execute_scan_operations import SqlVulnerabilityAssessmentExecuteScanOperations @@ -169,80 +169,106 @@ from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations from ._sql_vulnerability_assessments_settings_operations import SqlVulnerabilityAssessmentsSettingsOperations from ._sql_vulnerability_assessments_operations import SqlVulnerabilityAssessmentsOperations -from ._database_sql_vulnerability_assessment_baselines_operations import ( - DatabaseSqlVulnerabilityAssessmentBaselinesOperations, -) -from ._database_sql_vulnerability_assessment_execute_scan_operations import ( - DatabaseSqlVulnerabilityAssessmentExecuteScanOperations, -) -from ._database_sql_vulnerability_assessment_rule_baselines_operations import ( - DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations, -) -from ._database_sql_vulnerability_assessment_scan_result_operations import ( - DatabaseSqlVulnerabilityAssessmentScanResultOperations, -) -from ._database_sql_vulnerability_assessment_scans_operations import DatabaseSqlVulnerabilityAssessmentScansOperations -from ._database_sql_vulnerability_assessments_settings_operations import ( - DatabaseSqlVulnerabilityAssessmentsSettingsOperations, -) +from ._start_stop_managed_instance_schedules_operations import StartStopManagedInstanceSchedulesOperations +from ._subscription_usages_operations import SubscriptionUsagesOperations +from ._synapse_link_workspaces_operations import SynapseLinkWorkspacesOperations +from ._sync_agents_operations import SyncAgentsOperations +from ._sync_groups_operations import SyncGroupsOperations +from ._sync_members_operations import SyncMembersOperations +from ._tde_certificates_operations import TdeCertificatesOperations +from ._time_zones_operations import TimeZonesOperations +from ._transparent_data_encryptions_operations import TransparentDataEncryptionsOperations +from ._usages_operations import UsagesOperations +from ._virtual_clusters_operations import VirtualClustersOperations +from ._virtual_network_rules_operations import VirtualNetworkRulesOperations +from ._workload_classifiers_operations import WorkloadClassifiersOperations +from ._workload_groups_operations import WorkloadGroupsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "BackupShortTermRetentionPoliciesOperations", + "ServerBlobAuditingPoliciesOperations", + "DatabaseBlobAuditingPoliciesOperations", + "ExtendedDatabaseBlobAuditingPoliciesOperations", + "ExtendedServerBlobAuditingPoliciesOperations", "DataMaskingPoliciesOperations", "DataMaskingRulesOperations", - "GeoBackupPoliciesOperations", - "DatabasesOperations", - "ElasticPoolsOperations", - "ServerCommunicationLinksOperations", - "ServiceObjectivesOperations", - "ElasticPoolActivitiesOperations", - "ElasticPoolDatabaseActivitiesOperations", - "ServerUsagesOperations", + "DataWarehouseUserActivitiesOperations", + "DatabaseAdvancedThreatProtectionSettingsOperations", "DatabaseAdvisorsOperations", "DatabaseAutomaticTuningOperations", "DatabaseColumnsOperations", + "DatabaseEncryptionProtectorsOperations", + "DatabaseExtensionsOperations", + "DatabaseOperationsOperations", "DatabaseRecommendedActionsOperations", "DatabaseSchemasOperations", "DatabaseSecurityAlertPoliciesOperations", + "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", + "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", + "DatabaseSqlVulnerabilityAssessmentScanResultOperations", + "DatabaseSqlVulnerabilityAssessmentScansOperations", + "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", "DatabaseTablesOperations", + "DatabaseUsagesOperations", "DatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseVulnerabilityAssessmentsOperations", "DatabaseVulnerabilityAssessmentScansOperations", - "DataWarehouseUserActivitiesOperations", + "DatabaseVulnerabilityAssessmentsOperations", + "DatabasesOperations", "DeletedServersOperations", + "DistributedAvailabilityGroupsOperations", "ElasticPoolOperationsOperations", + "ElasticPoolsOperations", "EncryptionProtectorsOperations", + "EndpointCertificatesOperations", + "FailoverGroupsOperations", "FirewallRulesOperations", + "GeoBackupPoliciesOperations", + "IPv6FirewallRulesOperations", + "InstanceFailoverGroupsOperations", "InstancePoolsOperations", "JobAgentsOperations", "JobCredentialsOperations", "JobExecutionsOperations", - "JobsOperations", + "JobPrivateEndpointsOperations", "JobStepExecutionsOperations", "JobStepsOperations", "JobTargetExecutionsOperations", "JobTargetGroupsOperations", "JobVersionsOperations", + "JobsOperations", + "LedgerDigestUploadsOperations", "CapabilitiesOperations", + "LongTermRetentionBackupsOperations", + "LongTermRetentionManagedInstanceBackupsOperations", "LongTermRetentionPoliciesOperations", "MaintenanceWindowOptionsOperations", "MaintenanceWindowsOperations", "ManagedBackupShortTermRetentionPoliciesOperations", + "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", "ManagedDatabaseColumnsOperations", + "ManagedDatabaseMoveOperationsOperations", "ManagedDatabaseQueriesOperations", + "ManagedDatabaseRestoreDetailsOperations", "ManagedDatabaseSchemasOperations", "ManagedDatabaseSecurityAlertPoliciesOperations", "ManagedDatabaseSecurityEventsOperations", + "ManagedDatabaseSensitivityLabelsOperations", + "ManagedDatabaseRecommendedSensitivityLabelsOperations", "ManagedDatabaseTablesOperations", "ManagedDatabaseTransparentDataEncryptionOperations", "ManagedDatabaseVulnerabilityAssessmentRuleBaselinesOperations", - "ManagedDatabaseVulnerabilityAssessmentsOperations", "ManagedDatabaseVulnerabilityAssessmentScansOperations", + "ManagedDatabaseVulnerabilityAssessmentsOperations", + "ManagedDatabasesOperations", "ManagedInstanceAdministratorsOperations", + "ManagedInstanceAdvancedThreatProtectionSettingsOperations", "ManagedInstanceAzureADOnlyAuthenticationsOperations", + "ManagedInstanceDtcsOperations", "ManagedInstanceEncryptionProtectorsOperations", "ManagedInstanceKeysOperations", "ManagedInstanceLongTermRetentionPoliciesOperations", @@ -251,80 +277,42 @@ "ManagedInstancePrivateLinkResourcesOperations", "ManagedInstanceTdeCertificatesOperations", "ManagedInstanceVulnerabilityAssessmentsOperations", + "ManagedInstancesOperations", + "ManagedLedgerDigestUploadsOperations", "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations", + "ManagedServerDnsAliasesOperations", "ManagedServerSecurityAlertPoliciesOperations", + "NetworkSecurityPerimeterConfigurationsOperations", "Operations", + "OutboundFirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinkResourcesOperations", + "RecoverableDatabasesOperations", "RecoverableManagedDatabasesOperations", + "ReplicationLinksOperations", + "RestorableDroppedDatabasesOperations", + "RestorableDroppedManagedDatabasesOperations", "RestorePointsOperations", + "SensitivityLabelsOperations", + "RecommendedSensitivityLabelsOperations", + "ServerAdvancedThreatProtectionSettingsOperations", "ServerAdvisorsOperations", "ServerAutomaticTuningOperations", "ServerAzureADAdministratorsOperations", "ServerAzureADOnlyAuthenticationsOperations", + "ServerConfigurationOptionsOperations", + "ServerConnectionPoliciesOperations", "ServerDevOpsAuditSettingsOperations", "ServerDnsAliasesOperations", "ServerKeysOperations", "ServerOperationsOperations", "ServerSecurityAlertPoliciesOperations", + "ServerTrustCertificatesOperations", "ServerTrustGroupsOperations", + "ServerUsagesOperations", "ServerVulnerabilityAssessmentsOperations", - "SqlAgentOperations", - "SubscriptionUsagesOperations", - "SyncAgentsOperations", - "SyncGroupsOperations", - "SyncMembersOperations", - "TdeCertificatesOperations", - "TimeZonesOperations", - "VirtualNetworkRulesOperations", - "WorkloadClassifiersOperations", - "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseOperationsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "DistributedAvailabilityGroupsOperations", - "ServerTrustCertificatesOperations", - "EndpointCertificatesOperations", - "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", - "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", - "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", - "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", - "ReplicationLinksOperations", - "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", - "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", - "ManagedInstancesOperations", - "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", "ServersOperations", - "StartStopManagedInstanceSchedulesOperations", - "TransparentDataEncryptionsOperations", - "FailoverGroupsOperations", - "IPv6FirewallRulesOperations", + "SqlAgentOperations", "SqlVulnerabilityAssessmentBaselineOperations", "SqlVulnerabilityAssessmentBaselinesOperations", "SqlVulnerabilityAssessmentExecuteScanOperations", @@ -334,12 +322,20 @@ "SqlVulnerabilityAssessmentScansOperations", "SqlVulnerabilityAssessmentsSettingsOperations", "SqlVulnerabilityAssessmentsOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", + "StartStopManagedInstanceSchedulesOperations", + "SubscriptionUsagesOperations", + "SynapseLinkWorkspacesOperations", + "SyncAgentsOperations", + "SyncGroupsOperations", + "SyncMembersOperations", + "TdeCertificatesOperations", + "TimeZonesOperations", + "TransparentDataEncryptionsOperations", + "UsagesOperations", + "VirtualClustersOperations", + "VirtualNetworkRulesOperations", + "WorkloadClassifiersOperations", + "WorkloadGroupsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() 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 39469cac3b3d..23854b806758 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies", ) # pylint: disable=line-too-long 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"), } @@ -76,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -87,8 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,14 +104,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -128,7 +120,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -155,27 +147,34 @@ def build_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.ShortTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", ) # pylint: disable=line-too-long 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"), } @@ -185,9 +184,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class BackupShortTermRetentionPoliciesOperations: @@ -209,6 +210,101 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 BackupShortTermRetentionPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies" + } + @distributed_trace def get( self, @@ -245,7 +341,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -304,7 +400,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -484,7 +580,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -551,7 +647,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.BackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -731,7 +827,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -777,87 +873,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 BackupShortTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.BackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.BackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupShortTermRetentionPolicies" - } 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 81e9e7ce31a2..585fd71b46c7 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 @@ -44,7 +44,7 @@ def build_list_by_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,8 +98,8 @@ def list_by_location( :type location_name: str :param include: If specified, restricts the response to only include the selected item. Known values are: "supportedEditions", "supportedElasticPoolEditions", - "supportedManagedInstanceVersions", "supportedInstancePoolEditions", and - "supportedManagedInstanceEditions". Default value is None. + "supportedManagedInstanceVersions", "supportedInstancePoolEditions", + "supportedManagedInstanceEditions", and "supportedJobAgentVersions". Default value is None. :type include: str or ~azure.mgmt.sql.models.CapabilityGroup :keyword callable cls: A custom type or function that will be passed the direct response :return: LocationCapabilities or the result of cls(response) @@ -117,7 +117,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LocationCapabilities] = kwargs.pop("cls", None) request = build_list_by_location_request( 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 25458041b83d..3b711f4fa8fc 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 @@ -7,7 +7,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -29,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,15 +35,18 @@ _SERIALIZER.client_side_validation = False -def build_create_or_update_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_get_request( + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,11 +55,11 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -70,21 +68,24 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,11 +94,11 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -106,9 +107,11 @@ def build_get_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class DataMaskingPoliciesOperations: @@ -130,12 +133,89 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def get( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Gets the database data masking policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataMaskingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_policy_name=data_masking_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DataMaskingPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" + } + @overload def create_or_update( self, resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: _models.DataMaskingPolicy, *, content_type: str = "application/json", @@ -150,15 +230,14 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy @@ -171,6 +250,7 @@ def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: IO, *, content_type: str = "application/json", @@ -185,15 +265,14 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy @@ -206,6 +285,7 @@ def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], parameters: Union[_models.DataMaskingPolicy, IO], **kwargs: Any ) -> _models.DataMaskingPolicy: @@ -218,13 +298,12 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param parameters: Parameters for creating or updating a data masking policy. Is either a DataMaskingPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingPolicy or IO - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -244,8 +323,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) @@ -261,9 +339,9 @@ def create_or_update( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + data_masking_policy_name=data_masking_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, content=_content, @@ -281,90 +359,21 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } - - @distributed_trace - def get( - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataMaskingPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DataMaskingPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code == 200: + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get.metadata = { + create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}" } 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 d5b4ce8e4f60..263c9a3aec5c 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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,34 +37,31 @@ _SERIALIZER.client_side_validation = False -def build_create_or_update_request( +def build_list_by_database_request( resource_group_name: str, server_name: str, database_name: str, - data_masking_rule_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -77,34 +70,39 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + data_masking_rule_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -113,9 +111,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class DataMaskingRulesOperations: @@ -137,12 +137,116 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], + **kwargs: Any + ) -> Iterable["_models.DataMaskingRule"]: + """Gets a list of database data masking 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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking rule + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DataMaskingRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataMaskingRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + data_masking_policy_name=data_masking_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" + } + @overload def create_or_update( self, resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: _models.DataMaskingRule, *, @@ -158,6 +262,9 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. @@ -166,10 +273,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingRule @@ -182,6 +285,7 @@ def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: IO, *, @@ -197,6 +301,9 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. @@ -205,10 +312,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.sql.models.DataMaskingRule @@ -221,6 +324,7 @@ def create_or_update( resource_group_name: str, server_name: str, database_name: str, + data_masking_policy_name: Union[str, _models.DataMaskingPolicyName], data_masking_rule_name: str, parameters: Union[_models.DataMaskingRule, IO], **kwargs: Any @@ -234,15 +338,14 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str + :param data_masking_policy_name: The name of the database for which the data masking policy + applies. "Default" Required. + :type data_masking_policy_name: str or ~azure.mgmt.sql.models.DataMaskingPolicyName :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. Is either a DataMaskingRule type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.DataMaskingRule or IO - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -262,8 +365,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) @@ -279,10 +381,10 @@ def create_or_update( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, + data_masking_policy_name=data_masking_policy_name, data_masking_rule_name=data_masking_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, - data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, content=_content, @@ -318,92 +420,3 @@ def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.DataMaskingRule"]: - """Gets a list of database data masking 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :keyword data_masking_policy_name: The name of the database for which the data masking rule - applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataMaskingRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DataMaskingRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") - cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" - } 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 89a9a5b5b81b..ae78f88276e5 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -35,32 +36,24 @@ _SERIALIZER.client_side_validation = False -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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities", ) # pylint: disable=line-too-long 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"), } @@ -75,24 +68,32 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: 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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}", ) # pylint: disable=line-too-long 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"), } @@ -126,83 +127,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param data_warehouse_user_activity_name: The activity name of the data warehouse. "current" - Required. - :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 - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("DataWarehouseUserActivities", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" - } - @distributed_trace def list_by_database( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -225,7 +149,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataWarehouseUserActivitiesListResult] = kwargs.pop("cls", None) error_map = { @@ -253,7 +177,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -286,3 +221,80 @@ def get_next(next_link=None): list_by_database.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities" } + + @distributed_trace + def get( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param data_warehouse_user_activity_name: The activity name of the data warehouse. "current" + Required. + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DataWarehouseUserActivities", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" + } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py index c2df72ce17a4..27a127f4c574 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +120,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -192,7 +193,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -220,7 +221,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -292,7 +304,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -448,7 +460,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) 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 4df6ee12ef11..5f3b92088e88 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 @@ -47,7 +47,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +86,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +209,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) request = build_list_by_database_request( @@ -279,7 +279,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) request = build_get_request( @@ -429,7 +429,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) 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 f3c579813268..ae552757c700 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 @@ -41,7 +41,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +73,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -150,7 +150,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) request = build_get_request( @@ -290,7 +290,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseAutomaticTuning] = kwargs.pop("cls", None) 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 17e9a9cd1c52..df860b1b78cf 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +81,7 @@ def build_get_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +115,7 @@ def build_create_or_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -185,7 +186,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -213,7 +214,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -280,7 +292,7 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -431,7 +443,7 @@ def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) 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 dcbe0a6bdc4a..0394a38a419f 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -51,7 +52,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +102,7 @@ def build_list_by_table_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -144,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +234,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -266,7 +267,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -335,7 +347,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -366,7 +378,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -442,7 +465,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py index 373897ea66de..7fd869f0c25b 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_encryption_protectors_operations.py @@ -46,7 +46,7 @@ def build_revalidate_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -78,7 +78,7 @@ def build_revert_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -138,7 +138,7 @@ def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revalidate_request( @@ -209,7 +209,7 @@ def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -272,7 +272,7 @@ def _revert_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revert_request( @@ -343,7 +343,7 @@ def begin_revert( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 162e90dcc83e..d748f6a669e4 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,27 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions", ) # pylint: disable=line-too-long 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"), } @@ -67,10 +65,13 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( + +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -78,13 +79,9 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -103,32 +100,34 @@ def build_create_or_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}", ) # pylint: disable=line-too-long 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"), } @@ -138,9 +137,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class DatabaseExtensionsOperations: @@ -162,6 +163,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ImportExportExtensionsOperationResult"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 ImportExportExtensionsOperationResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions" + } + @distributed_trace def get( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, database_name: str, extension_name: str, **kwargs: Any @@ -193,7 +290,7 @@ def get( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_get_request( @@ -248,7 +345,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportExtensionsOperationResult]] = kwargs.pop("cls", None) @@ -313,7 +410,8 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -356,7 +454,8 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -397,7 +496,8 @@ def begin_create_or_update( parameters: Union[_models.DatabaseExtensions, IO], **kwargs: Any ) -> LROPoller[_models.ImportExportExtensionsOperationResult]: - """Perform a database extension operation, like polybase import. + """Perform a database extension operation, like database import, database export, or polybase + import. :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. Required. @@ -431,7 +531,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportExtensionsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -477,88 +577,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions/{extensionName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.ImportExportExtensionsOperationResult"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 ImportExportExtensionsOperationResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ImportExportExtensionsOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.ImportExportExtensionsOperationListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/extensions" - } 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 4364cfe4f0e4..ef02ccfde482 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -35,27 +36,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations", ) # pylint: disable=line-too-long 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"), } @@ -64,27 +62,33 @@ def build_cancel_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any + +def build_cancel_request( + resource_group_name: str, + server_name: str, + database_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel", ) # pylint: disable=line-too-long 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"), } @@ -93,10 +97,7 @@ def build_list_by_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class DatabaseOperationsOperations: @@ -118,72 +119,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param operation_id: The operation identifier. Required. - :type operation_id: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel" - } - @distributed_trace def list_by_database( self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -205,7 +140,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -233,7 +168,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -266,3 +212,69 @@ def get_next(next_link=None): list_by_database.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations" } + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param operation_id: The operation identifier. Required. + :type operation_id: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/operations/{operationId}/cancel" + } 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 b2d4f1bd18f3..d81afbdad9fb 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 @@ -46,7 +46,7 @@ def build_list_by_database_advisor_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +125,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -206,7 +206,7 @@ def list_by_database_advisor( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.RecommendedAction]] = kwargs.pop("cls", None) request = build_list_by_database_advisor_request( @@ -284,7 +284,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) request = build_get_request( @@ -444,7 +444,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RecommendedAction] = kwargs.pop("cls", None) 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 49fc9cee5708..6cdbe4a80af3 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +162,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) error_map = { @@ -190,7 +191,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -255,7 +267,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) request = build_get_request( 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 e4ec8691b407..8625b720d79f 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,30 +37,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies", ) # pylint: disable=line-too-long 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"), } @@ -74,7 +69,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -85,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,31 +102,36 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +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, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", ) # pylint: disable=line-too-long 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"), } @@ -142,9 +141,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class DatabaseSecurityAlertPoliciesOperations: @@ -166,6 +167,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DatabaseSecurityAlertPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database for which the security alert policy is defined. + Required. + :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 DatabaseSecurityAlertPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies" + } + @distributed_trace def get( self, @@ -185,7 +282,7 @@ def get( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: DatabaseSecurityAlertPolicy or the result of cls(response) @@ -203,7 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -264,7 +361,7 @@ def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy @@ -299,7 +396,7 @@ def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: IO @@ -332,7 +429,7 @@ def create_or_update( :param database_name: The name of the database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Is either a DatabaseSecurityAlertPolicy type or a IO type. Required. @@ -356,7 +453,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) @@ -410,88 +507,3 @@ def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.DatabaseSecurityAlertPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database for which the security alert policy is defined. - Required. - :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 DatabaseSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseSecurityAlertListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py index 18b7e2c145e8..a6f4b8844ef3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_baselines_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_sql_vulnerability_assessment_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +131,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -213,7 +214,7 @@ def list_by_sql_vulnerability_assessment( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -242,7 +243,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -318,7 +330,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( @@ -483,7 +495,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py index 3603d8ce93ab..13ba37fb3e9d 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_execute_scan_operations.py @@ -46,7 +46,7 @@ def build_execute_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -108,7 +108,7 @@ def _execute_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_execute_request( @@ -179,7 +179,7 @@ def begin_execute( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py index a67bc1f2e122..fcc293b5e3e5 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_rule_baselines_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -48,7 +49,7 @@ def build_list_by_baseline_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +136,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -181,7 +182,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -260,7 +261,7 @@ def list_by_baseline( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -290,7 +291,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -369,7 +381,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -543,7 +555,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -639,7 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py index 3b4ee61fe8de..5e19d881ce44 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scan_result_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_scan_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +91,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,7 +177,7 @@ def list_by_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -206,7 +207,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -285,7 +297,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py index d1d061b61d45..a170f827f739 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessment_scans_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -46,7 +47,7 @@ def build_list_by_sql_vulnerability_assessments_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,7 +88,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +168,7 @@ def list_by_sql_vulnerability_assessments( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -196,7 +197,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -270,7 +282,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py index e086d05c0817..e5e9085a071a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_database_sql_vulnerability_assessments_settings_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +79,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +149,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -176,7 +177,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -248,7 +260,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 fb37cea0ae07..4bd2fff66b70 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -48,7 +49,7 @@ def build_list_by_schema_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +169,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) error_map = { @@ -198,7 +199,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -271,7 +283,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) request = build_get_request( 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 3fdec29153ed..bcc1e6c9a7a7 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -135,7 +136,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 efa1c1071d70..edb88bf1c92c 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 @@ -48,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +92,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +138,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -229,7 +229,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -411,7 +411,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -510,7 +510,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 935eaed0a0de..dab8fe0d68b8 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -37,22 +38,24 @@ _SERIALIZER.client_side_validation = False -def build_initiate_scan_request( +def build_list_by_database_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}/initiateScan", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -61,7 +64,6 @@ def build_initiate_scan_request( "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"), } @@ -70,27 +72,31 @@ def build_initiate_scan_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( + +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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -99,6 +105,7 @@ def build_list_by_database_request( "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"), } @@ -113,7 +120,7 @@ def build_list_by_database_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_export_request( resource_group_name: str, server_name: str, database_name: str, @@ -125,13 +132,13 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -152,10 +159,10 @@ def build_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_export_request( +def build_initiate_scan_request( resource_group_name: str, server_name: str, database_name: str, @@ -164,16 +171,13 @@ def build_export_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -191,10 +195,7 @@ def build_export_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class DatabaseVulnerabilityAssessmentScansOperations: @@ -216,144 +217,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - server_name: str, - database_name: str, - vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_initiate_scan_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, - api_version=api_version, - template_url=self._initiate_scan_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } - - @distributed_trace - def begin_initiate_scan( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. - :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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._initiate_scan_initial( # type: ignore - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - scan_id=scan_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } - @distributed_trace def list_by_database( self, @@ -384,7 +247,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -413,7 +276,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -487,7 +361,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( @@ -567,7 +441,7 @@ def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) request = build_export_request( @@ -610,3 +484,141 @@ def export( export.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" } + + def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + server_name: str, + database_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_initiate_scan_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, + api_version=api_version, + template_url=self._initiate_scan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _initiate_scan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + } + + @distributed_trace + def begin_initiate_scan( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentName + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. + :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. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._initiate_scan_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + vulnerability_assessment_name=vulnerability_assessment_name, + scan_id=scan_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_initiate_scan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + } 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 d4bbb6029731..79431fc4baf9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,32 +37,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments", ) # pylint: disable=line-too-long 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"), } @@ -76,7 +69,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -87,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,14 +104,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -127,9 +117,13 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -150,27 +144,37 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any + +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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", ) # pylint: disable=line-too-long 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"), } @@ -179,10 +183,7 @@ def build_list_by_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class DatabaseVulnerabilityAssessmentsOperations: @@ -204,6 +205,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DatabaseVulnerabilityAssessment"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database for which the vulnerability assessment policies + are defined. Required. + :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 DatabaseVulnerabilityAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments" + } + @distributed_trace def get( self, @@ -242,7 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -398,7 +495,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -491,7 +588,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -525,88 +622,3 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.DatabaseVulnerabilityAssessment"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database for which the vulnerability assessment policies - are defined. Required. - :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 DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments" - } 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 9298d52fb017..b792b8c2f3d4 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,78 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_metrics_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, *, filter: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_metric_definitions_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_list_by_server_request( resource_group_name: str, server_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -185,7 +121,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -219,7 +155,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -246,7 +182,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -281,7 +217,7 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -321,7 +257,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -350,7 +286,7 @@ def build_import_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -385,7 +321,7 @@ def build_rename_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -417,7 +353,7 @@ def build_pause_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -449,7 +385,7 @@ def build_resume_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -480,7 +416,7 @@ def build_upgrade_data_warehouse_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -507,7 +443,7 @@ def build_list_by_elastic_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -539,7 +475,7 @@ def build_list_inaccessible_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -583,176 +519,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_metrics( - self, resource_group_name: str, server_name: str, database_name: str, filter: str, **kwargs: Any - ) -> Iterable["_models.Metric"]: - """Returns database metrics. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. - Required. - :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 Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metrics_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_metrics.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metrics" - } - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Returns database metric definitions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metric_definitions_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_metric_definitions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metric_definitions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/metricDefinitions" - } - @distributed_trace def list_by_server( self, resource_group_name: str, server_name: str, skip_token: Optional[str] = None, **kwargs: Any @@ -774,7 +540,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -802,7 +568,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -876,7 +653,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) request = build_get_request( @@ -935,7 +712,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) @@ -1105,7 +882,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1167,7 +944,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -1229,7 +1006,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1291,7 +1068,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) @@ -1458,7 +1235,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1525,7 +1302,7 @@ def _export_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -1695,7 +1472,7 @@ def begin_export( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1760,7 +1537,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1831,7 +1608,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1892,7 +1669,7 @@ def _import_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -2062,7 +1839,7 @@ def begin_import_method( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -2210,7 +1987,7 @@ def rename( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -2270,7 +2047,7 @@ def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) request = build_pause_request( @@ -2338,7 +2115,7 @@ def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2395,7 +2172,7 @@ def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Database]] = kwargs.pop("cls", None) request = build_resume_request( @@ -2463,7 +2240,7 @@ def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2520,7 +2297,7 @@ def _upgrade_data_warehouse_initial( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_upgrade_data_warehouse_request( @@ -2582,7 +2359,7 @@ def begin_upgrade_data_warehouse( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2644,7 +2421,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2672,7 +2449,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -2725,7 +2513,7 @@ def list_inaccessible_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2752,7 +2540,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 3198197bdd83..e255f67b5308 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,21 +62,20 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request(location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_list_by_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers", ) # pylint: disable=line-too-long 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"), } @@ -90,20 +90,21 @@ def build_get_request(location_name: str, deleted_server_name: str, subscription return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_location_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_request(location_name: str, deleted_server_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}", ) # pylint: disable=line-too-long 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"), } @@ -124,7 +125,7 @@ def build_recover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +181,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DeletedServer"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) error_map = { @@ -205,7 +206,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -237,67 +249,6 @@ def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers"} - @distributed_trace - def get(self, 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. Required. - :type location_name: str - :param deleted_server_name: The name of the deleted server. Required. - :type deleted_server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedServer or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DeletedServer - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) - - request = build_get_request( - location_name=location_name, - deleted_server_name=deleted_server_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("DeletedServer", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}" - } - @distributed_trace def list_by_location(self, location_name: str, **kwargs: Any) -> Iterable["_models.DeletedServer"]: """Gets a list of deleted servers for a location. @@ -312,7 +263,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> Iterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServerListResult] = kwargs.pop("cls", None) error_map = { @@ -338,7 +289,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -372,6 +334,67 @@ def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers" } + @distributed_trace + def get(self, 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. Required. + :type location_name: str + :param deleted_server_name: The name of the deleted server. Required. + :type deleted_server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedServer or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.DeletedServer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) + + request = build_get_request( + location_name=location_name, + deleted_server_name=deleted_server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("DeletedServer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/deletedServers/{deletedServerName}" + } + def _recover_initial( self, location_name: str, deleted_server_name: str, **kwargs: Any ) -> Optional[_models.DeletedServer]: @@ -386,7 +409,7 @@ def _recover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.DeletedServer]] = kwargs.pop("cls", None) request = build_recover_request( @@ -451,7 +474,7 @@ def begin_recover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedServer] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py index 5b1585b30a49..ce6e242ed2db 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_distributed_availability_groups_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -190,7 +191,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -221,6 +222,47 @@ def build_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) +def build_set_role_request( + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "distributedAvailabilityGroupName": _SERIALIZER.url( + "distributed_availability_group_name", distributed_availability_group_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class DistributedAvailabilityGroupsOperations: """ .. warning:: @@ -260,7 +302,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DistributedAvailabilityGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -287,7 +329,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -354,7 +407,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -411,7 +464,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) @@ -584,7 +637,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -648,7 +701,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -714,7 +767,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -774,7 +827,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) @@ -944,7 +997,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -989,3 +1042,240 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}" } + + def _set_role_initial( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO], + **kwargs: Any + ) -> Optional[_models.DistributedAvailabilityGroup]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.DistributedAvailabilityGroup]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupSetRole") + + request = build_set_role_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._set_role_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _set_role_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole" + } + + @overload + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: _models.DistributedAvailabilityGroupSetRole, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_set_role( + self, + resource_group_name: str, + managed_instance_name: str, + distributed_availability_group_name: str, + parameters: Union[_models.DistributedAvailabilityGroupSetRole, IO], + **kwargs: Any + ) -> LROPoller[_models.DistributedAvailabilityGroup]: + """Sets the role for managed instance in a distributed availability 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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param distributed_availability_group_name: The distributed availability group name. Required. + :type distributed_availability_group_name: str + :param parameters: The distributed availability group set role request parameters. Is either a + DistributedAvailabilityGroupSetRole type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupSetRole or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DistributedAvailabilityGroup or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.DistributedAvailabilityGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DistributedAvailabilityGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._set_role_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + distributed_availability_group_name=distributed_availability_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DistributedAvailabilityGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_set_role.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}/setRole" + } 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 deleted file mode 100644 index 8e28dbc9e28b..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -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_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ElasticPoolActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pool_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> Iterable["_models.ElasticPoolActivity"]: - """Returns elastic pool activities. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool for which to get the current activity. - Required. - :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 ElasticPoolActivity or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolActivityListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_elastic_pool.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_elastic_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolActivity" - } 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 deleted file mode 100644 index 5d7bbbb4c08f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -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_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ElasticPoolDatabaseActivitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`elastic_pool_database_activities` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_elastic_pool( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> Iterable["_models.ElasticPoolDatabaseActivity"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :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 ElasticPoolDatabaseActivity or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ElasticPoolDatabaseActivityListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_elastic_pool_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_elastic_pool.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_elastic_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/elasticPoolDatabaseActivity" - } 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 75243cfd281a..71b782214c94 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -35,27 +36,24 @@ _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 +def build_list_by_elastic_pool_request( + resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations", ) # pylint: disable=line-too-long 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"), } @@ -64,27 +62,33 @@ def build_cancel_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_elastic_pool_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any + +def build_cancel_request( + resource_group_name: str, + server_name: str, + elastic_pool_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel", ) # pylint: disable=line-too-long 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"), } @@ -93,10 +97,7 @@ def build_list_by_elastic_pool_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class ElasticPoolOperationsOperations: @@ -118,72 +119,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: Required. - :type elastic_pool_name: str - :param operation_id: The operation identifier. Required. - :type operation_id: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel" - } - @distributed_trace def list_by_elastic_pool( self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any @@ -206,7 +141,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPoolOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -234,7 +169,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -267,3 +213,69 @@ def get_next(next_link=None): list_by_elastic_pool.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations" } + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param elastic_pool_name: Required. + :type elastic_pool_name: str + :param operation_id: The operation identifier. Required. + :type operation_id: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.cancel.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel" + } 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 83074f5bf19a..b6ba9da0451e 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,84 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_metrics_request( - resource_group_name: str, - server_name: str, - elastic_pool_name: str, - subscription_id: str, - *, - filter: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_metric_definitions_request( - resource_group_name: str, server_name: str, elastic_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_list_by_server_request( resource_group_name: str, server_name: str, subscription_id: str, *, skip: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +110,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -214,7 +144,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -241,7 +171,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -275,7 +205,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -315,176 +245,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_metrics( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, filter: str, **kwargs: Any - ) -> Iterable["_models.Metric"]: - """Returns elastic pool metrics. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :type elastic_pool_name: str - :param filter: An OData filter expression that describes a subset of metrics to return. - Required. - :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 Metric or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.Metric] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metrics_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - filter=filter, - api_version=api_version, - template_url=self.list_metrics.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metrics" - } - - @distributed_trace - def list_metric_definitions( - self, resource_group_name: str, server_name: str, elastic_pool_name: str, **kwargs: Any - ) -> Iterable["_models.MetricDefinition"]: - """Returns elastic pool metric definitions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param elastic_pool_name: The name of the elastic pool. Required. - :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 MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.MetricDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.MetricDefinitionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_metric_definitions_request( - resource_group_name=resource_group_name, - server_name=server_name, - elastic_pool_name=elastic_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_metric_definitions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_metric_definitions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/metricDefinitions" - } - @distributed_trace def list_by_server( self, resource_group_name: str, server_name: str, skip: Optional[int] = None, **kwargs: Any @@ -506,7 +266,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPoolListResult] = kwargs.pop("cls", None) error_map = { @@ -534,7 +294,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -597,7 +368,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) request = build_get_request( @@ -654,7 +425,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ElasticPool]] = kwargs.pop("cls", None) @@ -827,7 +598,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -889,7 +660,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -951,7 +722,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1013,7 +784,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ElasticPool]] = kwargs.pop("cls", None) @@ -1183,7 +954,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ElasticPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1245,7 +1016,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1307,7 +1078,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 b034c5e911a1..f1656666b33f 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +154,7 @@ def build_revalidate_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -212,7 +213,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) error_map = { @@ -239,7 +240,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -307,7 +319,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) request = build_get_request( @@ -364,7 +376,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.EncryptionProtector]] = kwargs.pop("cls", None) @@ -537,7 +549,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -601,7 +613,7 @@ def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_revalidate_request( @@ -668,7 +680,7 @@ def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py index 2e2b0abc74a3..8baf91b84c17 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_endpoint_certificates_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +137,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointCertificateListResult] = kwargs.pop("cls", None) error_map = { @@ -163,7 +164,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -227,7 +239,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointCertificate] = kwargs.pop("cls", None) request = build_get_request( 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 42d7541c5011..7e0abdef891f 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +81,7 @@ def build_get_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +115,7 @@ def build_create_or_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -185,7 +186,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -213,7 +214,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -280,7 +292,7 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -431,7 +443,7 @@ def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedDatabaseBlobAuditingPolicy] = kwargs.pop("cls", None) 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 4c702483a4ca..5b273853be88 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -49,7 +50,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request(resource_group_name: str, server_name: str, subscription_i _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +113,7 @@ def build_create_or_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,7 +181,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -207,7 +208,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -272,7 +284,7 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -329,7 +341,7 @@ def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] = kwargs.pop("cls", None) @@ -500,7 +512,7 @@ def begin_create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 7c3777e46484..3917830bf2fd 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -168,7 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +204,7 @@ def build_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +236,7 @@ def build_force_failover_allow_data_loss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -267,7 +268,7 @@ def build_try_planned_before_forced_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -331,7 +332,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -358,7 +359,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -421,7 +433,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -478,7 +490,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) @@ -651,7 +663,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -711,7 +723,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -773,7 +785,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -833,7 +845,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) @@ -1003,7 +1015,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1063,7 +1075,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -1132,7 +1144,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1189,7 +1201,7 @@ def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -1259,7 +1271,7 @@ def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1316,7 +1328,7 @@ def _try_planned_before_forced_failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.FailoverGroup]] = kwargs.pop("cls", None) request = build_try_planned_before_forced_failover_request( @@ -1390,7 +1402,7 @@ def begin_try_planned_before_forced_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 66f2f4b8d30d..58002fe12aae 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,24 +37,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", ) # pylint: disable=line-too-long 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"), } @@ -68,25 +68,24 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( - resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any +def build_replace_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", ) # pylint: disable=line-too-long 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"), } @@ -103,12 +102,15 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_get_request( resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -126,26 +128,31 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", ) # pylint: disable=line-too-long 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"), } @@ -155,29 +162,28 @@ def build_list_by_server_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_replace_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, server_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}", ) # pylint: disable=line-too-long 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"), } @@ -186,12 +192,7 @@ def build_replace_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class FirewallRulesOperations: @@ -214,23 +215,27 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets a firewall rule. + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.FirewallRule"]: + """Gets a list of 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: An iterator like instance of either FirewallRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FirewallRule] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -239,136 +244,142 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - 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) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("FirewallRule", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + list_by_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" } @overload - def create_or_update( + def replace( self, resource_group_name: str, server_name: str, - firewall_rule_name: str, - parameters: _models.FirewallRule, + parameters: _models.FirewallRuleList, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def replace( self, resource_group_name: str, server_name: str, - firewall_rule_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Required. + :param parameters: Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( - self, - resource_group_name: str, - server_name: str, - firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], - **kwargs: Any - ) -> _models.FirewallRule: - """Creates or updates a firewall rule. + def replace( + self, resource_group_name: str, server_name: str, parameters: Union[_models.FirewallRuleList, IO], **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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param firewall_rule_name: The name of the firewall rule. Required. - :type firewall_rule_name: str - :param parameters: The required parameters for creating or updating a firewall rule. Is either - a FirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO + :param parameters: Is either a FirewallRuleList type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule + :return: FirewallRule or None or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -382,9 +393,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -392,18 +403,17 @@ def create_or_update( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "FirewallRule") + _json = self._serialize.body(parameters, "FirewallRuleList") - request = build_create_or_update_request( + request = build_replace_request( resource_group_name=resource_group_name, server_name=server_name, - firewall_rule_name=firewall_rule_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self.replace.metadata["url"], headers=_headers, params=_params, ) @@ -417,30 +427,28 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: deserialized = self._deserialize("FirewallRule", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("FirewallRule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) - return deserialized # type: ignore + return deserialized - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + replace.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" } @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def get( self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any - ) -> None: - """Deletes a firewall rule. + ) -> _models.FirewallRule: + """Gets a 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. Required. @@ -450,8 +458,8 @@ def delete( # pylint: disable=inconsistent-return-statements :param firewall_rule_name: The name of the firewall rule. Required. :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 + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -465,16 +473,16 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - request = build_delete_request( + 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, api_version=api_version, - template_url=self.delete.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -488,172 +496,110 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" - } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.FirewallRule"]: - """Gets a list of 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 FirewallRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.FirewallRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("FirewallRule", pipeline_response) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) - return ItemPaged(get_next, extract_data) + return deserialized - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" } @overload - def replace( + def create_or_update( self, resource_group_name: str, server_name: str, - parameters: _models.FirewallRuleList, + firewall_rule_name: str, + parameters: _models.FirewallRule, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + ) -> _models.FirewallRule: + """Creates or updates a 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def replace( + def create_or_update( self, resource_group_name: str, server_name: str, + firewall_rule_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + ) -> _models.FirewallRule: + """Creates or updates a 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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Required. + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def replace( - self, resource_group_name: str, server_name: str, parameters: Union[_models.FirewallRuleList, IO], **kwargs: Any - ) -> Optional[_models.FirewallRule]: - """Replaces all firewall rules on the server. + def create_or_update( + self, + resource_group_name: str, + server_name: str, + firewall_rule_name: str, + parameters: Union[_models.FirewallRule, IO], + **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 obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Is either a FirewallRuleList type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.FirewallRuleList or IO + :param firewall_rule_name: The name of the firewall rule. Required. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. Is either + a FirewallRule type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.FirewallRule or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FirewallRule or None or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.FirewallRule or None + :return: FirewallRule or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -667,9 +613,9 @@ def replace( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.FirewallRule]] = kwargs.pop("cls", None) + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -677,17 +623,18 @@ def replace( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "FirewallRuleList") + _json = self._serialize.body(parameters, "FirewallRule") - request = build_replace_request( + 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, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.replace.metadata["url"], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -701,19 +648,84 @@ def replace( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + 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) - deserialized = None if response.status_code == 200: deserialized = self._deserialize("FirewallRule", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("FirewallRule", pipeline_response) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - replace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules" + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/firewallRules/{firewallRuleName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param firewall_rule_name: The name of the firewall rule. Required. + :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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/firewallRules/{firewallRuleName}" } 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 d905049a1229..11e3385da22c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,32 +37,25 @@ _SERIALIZER.client_side_validation = False -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - database_name: str, - geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - subscription_id: str, - **kwargs: Any +def build_list_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -70,11 +64,9 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -88,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,11 +89,11 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -115,25 +107,32 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -142,9 +141,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class GeoBackupPoliciesOperations: @@ -166,6 +167,176 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.GeoBackupPolicy"]: + """Gets a list of Geo backup policies for the given database resource. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies" + } + + @distributed_trace + def get( + self, + 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 for the given database resource. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. + :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + geo_backup_policy_name=geo_backup_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("GeoBackupPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" + } + @overload def create_or_update( self, @@ -178,7 +349,7 @@ def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -187,7 +358,8 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Required. @@ -213,7 +385,7 @@ def create_or_update( content_type: str = "application/json", **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -222,7 +394,8 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Required. @@ -246,7 +419,7 @@ def create_or_update( parameters: Union[_models.GeoBackupPolicy, IO], **kwargs: Any ) -> _models.GeoBackupPolicy: - """Updates a database geo backup policy. + """Create or update a database default Geo backup policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -255,7 +428,8 @@ def create_or_update( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. + :param geo_backup_policy_name: The name of the Geo backup policy. This should always be + 'Default'. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Is either a GeoBackupPolicy type or a IO type. Required. @@ -279,7 +453,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) @@ -333,161 +507,3 @@ def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" } - - @distributed_trace - def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. - :type geo_backup_policy_name: str or ~azure.mgmt.sql.models.GeoBackupPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.GeoBackupPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - geo_backup_policy_name=geo_backup_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("GeoBackupPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies/{geoBackupPolicyName}" - } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.GeoBackupPolicy"]: - """Returns a list of geo backup policies. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 GeoBackupPolicy or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.GeoBackupPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/geoBackupPolicies" - } 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 7105963bcc0a..656b875117cf 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -168,7 +169,7 @@ def build_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -200,7 +201,7 @@ def build_force_failover_allow_data_loss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -265,7 +266,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -292,7 +293,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -355,7 +367,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -412,7 +424,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) @@ -585,7 +597,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -645,7 +657,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -707,7 +719,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -762,7 +774,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -831,7 +843,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -888,7 +900,7 @@ def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.InstanceFailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -958,7 +970,7 @@ def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstanceFailoverGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 38e8be14d82c..5e45c1594a19 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,23 +39,16 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools") 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"), } @@ -69,24 +63,20 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( - resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools", ) # pylint: disable=line-too-long 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"), } @@ -96,19 +86,20 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_get_request( resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -125,16 +116,19 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( + +def build_create_or_update_request( resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,23 +153,23 @@ def build_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_delete_request( + resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", ) # pylint: disable=line-too-long 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"), } @@ -184,22 +178,27 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_update_request( + resource_group_name: str, instance_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}", + ) # pylint: disable=line-too-long 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"), } @@ -209,9 +208,11 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class InstancePoolsOperations: @@ -233,6 +234,172 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.InstancePool"]: + """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 InstancePool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.InstancePool"]: + """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. Required. + :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 InstancePool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools" + } + @distributed_trace def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) -> _models.InstancePool: """Gets an instance pool. @@ -258,7 +425,7 @@ def get(self, resource_group_name: str, instance_pool_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) request = build_get_request( @@ -313,7 +480,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstancePool]] = kwargs.pop("cls", None) @@ -476,7 +643,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -535,7 +702,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -592,7 +759,7 @@ def begin_delete(self, resource_group_name: str, instance_pool_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -650,7 +817,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.InstancePool]] = kwargs.pop("cls", None) @@ -810,7 +977,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InstancePool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -854,147 +1021,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}" } - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.InstancePool"]: - """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. Required. - :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 InstancePool or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools" - } - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.InstancePool"]: - """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 InstancePool or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.InstancePool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.InstancePoolListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/instancePools"} 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 index 09a67bbecd47..ee691f15eb5e 100644 --- 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +74,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +106,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -139,7 +140,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -198,7 +199,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -225,7 +226,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -288,7 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -430,7 +442,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IPv6FirewallRule] = kwargs.pop("cls", None) @@ -513,7 +525,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 1aac3feceabc..534aeb5504d5 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -168,7 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -233,7 +234,7 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobAgentListResult] = kwargs.pop("cls", None) error_map = { @@ -260,7 +261,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -321,7 +333,7 @@ def get(self, resource_group_name: str, server_name: str, job_agent_name: str, * _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) request = build_get_request( @@ -378,7 +390,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.JobAgent]] = kwargs.pop("cls", None) @@ -548,7 +560,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -608,7 +620,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -670,7 +682,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -730,7 +742,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.JobAgent]] = kwargs.pop("cls", None) @@ -897,7 +909,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobAgent] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 2be7e5407667..e88a86d8835e 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_agent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -219,7 +220,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobCredentialListResult] = kwargs.pop("cls", None) error_map = { @@ -247,7 +248,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -312,7 +324,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) request = build_get_request( @@ -462,7 +474,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobCredential] = kwargs.pop("cls", None) @@ -548,7 +560,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 9e1310883655..45463d28818c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -56,7 +57,7 @@ def build_list_by_agent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,59 +97,92 @@ def build_list_by_agent_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_request( +def build_list_by_job_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}/cancel", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if create_time_min is not None: + _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") + if create_time_max is not None: + _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") + if end_time_min is not None: + _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") + if end_time_max is not None: + _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") + if is_active is not None: + _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request( - resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any + +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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", ) # pylint: disable=line-too-long 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"), } @@ -160,70 +194,50 @@ def build_create_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_job_request( +def build_create_or_update_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_cancel_request( resource_group_name: str, server_name: str, job_agent_name: str, @@ -232,16 +246,13 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -257,38 +268,28 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_create_or_update_request( - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - subscription_id: str, - **kwargs: Any +def build_create_request( + resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start", ) # pylint: disable=line-too-long 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"), } @@ -300,7 +301,7 @@ def build_create_or_update_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class JobExecutionsOperations: @@ -373,7 +374,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -408,7 +409,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -443,7 +455,142 @@ def get_next(next_link=None): } @distributed_trace - def cancel( # pylint: disable=inconsistent-return-statements + def list_by_job( + self, + 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.JobExecution"]: + """Lists a job's executions. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param create_time_min: If specified, only job executions created at or after the specified + time are included. Default value is None. + :type create_time_min: ~datetime.datetime + :param create_time_max: If specified, only job executions created before the specified time are + included. Default value is None. + :type create_time_max: ~datetime.datetime + :param end_time_min: If specified, only job executions completed at or after the specified time + are included. Default value is None. + :type end_time_min: ~datetime.datetime + :param end_time_max: If specified, only job executions completed before the specified time are + included. Default value is None. + :type end_time_max: ~datetime.datetime + :param is_active: If specified, only active or only completed job executions are included. + Default value is None. + :type is_active: bool + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :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 JobExecution or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions" + } + + @distributed_trace + def get( self, resource_group_name: str, server_name: str, @@ -451,8 +598,8 @@ def cancel( # pylint: disable=inconsistent-return-statements job_name: str, job_execution_id: str, **kwargs: Any - ) -> None: - """Requests cancellation of a job execution. + ) -> _models.JobExecution: + """Gets a job execution. :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. Required. @@ -463,11 +610,11 @@ def cancel( # pylint: disable=inconsistent-return-statements :type job_agent_name: str :param job_name: The name of the job. Required. :type job_name: str - :param job_execution_id: The id of the job execution to cancel. Required. + :param job_execution_id: The id of the job execution. Required. :type job_execution_id: 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 + :return: JobExecution or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobExecution :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -481,10 +628,10 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - request = build_cancel_request( + request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, job_agent_name=job_agent_name, @@ -492,7 +639,7 @@ def cancel( # pylint: disable=inconsistent-return-statements job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -510,15 +657,25 @@ def cancel( # pylint: disable=inconsistent-return-statements map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("JobExecution", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel" + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } - def _create_initial( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any ) -> Optional[_models.JobExecution]: error_map = { 401: ClientAuthenticationError, @@ -531,17 +688,18 @@ def _create_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.JobExecution]] = kwargs.pop("cls", None) - request = build_create_request( + 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, + job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_initial.metadata["url"], + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -555,7 +713,7 @@ def _create_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -563,20 +721,29 @@ def _create_initial( if response.status_code == 200: deserialized = self._deserialize("JobExecution", pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("JobExecution", pipeline_response) + if cls: 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" + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } @distributed_trace - def begin_create( - self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_execution_id: str, + **kwargs: Any ) -> LROPoller[_models.JobExecution]: - """Starts an elastic job execution. + """Creates or updates a job execution. :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. Required. @@ -587,6 +754,8 @@ def begin_create( :type job_agent_name: str :param job_name: The name of the job to get. Required. :type job_name: str + :param job_execution_id: The job execution id to create the job execution under. Required. + :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 @@ -603,17 +772,18 @@ def begin_create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_or_update_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, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -643,136 +813,12 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" - } - - @distributed_trace - def list_by_job( - self, - 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.JobExecution"]: - """Lists a job's executions. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param create_time_min: If specified, only job executions created at or after the specified - time are included. Default value is None. - :type create_time_min: ~datetime.datetime - :param create_time_max: If specified, only job executions created before the specified time are - included. Default value is None. - :type create_time_max: ~datetime.datetime - :param end_time_min: If specified, only job executions completed at or after the specified time - are included. Default value is None. - :type end_time_min: ~datetime.datetime - :param end_time_max: If specified, only job executions completed before the specified time are - included. Default value is None. - :type end_time_max: ~datetime.datetime - :param is_active: If specified, only active or only completed job executions are included. - Default value is None. - :type is_active: bool - :param skip: The number of elements in the collection to skip. Default value is None. - :type skip: int - :param top: The number of elements to return from the collection. Default value is None. - :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 JobExecution or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobExecution] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_job.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_job.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions" + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" } @distributed_trace - def get( + def cancel( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, @@ -780,8 +826,8 @@ def get( job_name: str, job_execution_id: str, **kwargs: Any - ) -> _models.JobExecution: - """Gets a job execution. + ) -> None: + """Requests cancellation of a job execution. :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. Required. @@ -792,11 +838,11 @@ def get( :type job_agent_name: str :param job_name: The name of the job. Required. :type job_name: str - :param job_execution_id: The id of the job execution. Required. + :param job_execution_id: The id of the job execution to cancel. Required. :type job_execution_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -810,10 +856,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_request( + request = build_cancel_request( resource_group_name=resource_group_name, server_name=server_name, job_agent_name=job_agent_name, @@ -821,7 +867,7 @@ def get( job_execution_id=job_execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], + template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) @@ -839,25 +885,15 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("JobExecution", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/cancel" } - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any + def _create_initial( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any ) -> Optional[_models.JobExecution]: error_map = { 401: ClientAuthenticationError, @@ -870,18 +906,17 @@ def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.JobExecution]] = kwargs.pop("cls", None) - request = build_create_or_update_request( + request = build_create_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, api_version=api_version, - template_url=self._create_or_update_initial.metadata["url"], + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -895,7 +930,7 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -903,29 +938,20 @@ def _create_or_update_initial( if response.status_code == 200: deserialized = self._deserialize("JobExecution", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("JobExecution", pipeline_response) - if cls: 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}" + _create_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" } @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_execution_id: str, - **kwargs: Any + def begin_create( + self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any ) -> LROPoller[_models.JobExecution]: - """Creates or updates a job execution. + """Starts an elastic job execution. :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. Required. @@ -936,8 +962,6 @@ def begin_create_or_update( :type job_agent_name: str :param job_name: The name of the job to get. Required. :type job_name: str - :param job_execution_id: The job execution id to create the job execution under. Required. - :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 @@ -954,18 +978,17 @@ def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_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, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, @@ -995,6 +1018,6 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}" + begin_create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/start" } 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/_job_private_endpoints_operations.py similarity index 65% rename from sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py rename to sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_private_endpoints_operations.py index 4e722959c0ec..20c27e0925af 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/_job_private_endpoints_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,22 +39,25 @@ _SERIALIZER.client_side_validation = False -def build_delete_request( - resource_group_name: str, server_name: str, communication_link_name: str, subscription_id: str, **kwargs: Any +def build_list_by_agent_request( + resource_group_name: str, server_name: str, job_agent_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints", ) # pylint: disable=line-too-long 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"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -61,28 +65,37 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, server_name: str, communication_link_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", ) # pylint: disable=line-too-long 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"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -97,25 +110,31 @@ def build_get_request( def build_create_or_update_request( - resource_group_name: str, server_name: str, communication_link_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", ) # pylint: disable=line-too-long 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"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -131,24 +150,28 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, + server_name: str, + job_agent_name: str, + private_endpoint_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}", ) # pylint: disable=line-too-long 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"), + "jobAgentName": _SERIALIZER.url("job_agent_name", job_agent_name, "str"), + "privateEndpointName": _SERIALIZER.url("private_endpoint_name", private_endpoint_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -156,20 +179,17 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -class ServerCommunicationLinksOperations: +class JobPrivateEndpointsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`server_communication_links` attribute. + :attr:`job_private_endpoints` attribute. """ models = _models @@ -182,23 +202,29 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, communication_link_name: str, **kwargs: Any - ) -> None: - """Deletes a server communication link. + def list_by_agent( + self, resource_group_name: str, server_name: str, job_agent_name: str, **kwargs: Any + ) -> Iterable["_models.JobPrivateEndpoint"]: + """Gets a list of job agent private endpoints. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_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 + :return: An iterator like instance of either JobPrivateEndpoint or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobPrivateEndpointListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -207,59 +233,86 @@ def delete( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_by_agent.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_delete_request( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("JobPrivateEndpointListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - 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) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + 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}/privateEndpoints" } @distributed_trace def get( - self, resource_group_name: str, server_name: str, communication_link_name: str, **kwargs: Any - ) -> _models.ServerCommunicationLink: - """Returns a server communication link. + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> _models.JobPrivateEndpoint: + """Gets a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to get. Required. + :type private_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerCommunicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerCommunicationLink + :return: JobPrivateEndpoint or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobPrivateEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -273,13 +326,14 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], @@ -300,7 +354,7 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -308,17 +362,18 @@ def get( return deserialized get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } def _create_or_update_initial( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, IO], **kwargs: Any - ) -> Optional[_models.ServerCommunicationLink]: + ) -> Optional[_models.JobPrivateEndpoint]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -330,9 +385,9 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerCommunicationLink]] = kwargs.pop("cls", None) + cls: ClsType[Optional[_models.JobPrivateEndpoint]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -340,12 +395,13 @@ def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "ServerCommunicationLink") + _json = self._serialize.body(parameters, "JobPrivateEndpoint") request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, @@ -365,13 +421,16 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [201, 202]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -379,7 +438,7 @@ def _create_or_update_initial( return deserialized _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } @overload @@ -387,23 +446,26 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: _models.ServerCommunicationLink, + job_agent_name: str, + private_endpoint_name: str, + parameters: _models.JobPrivateEndpoint, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -415,9 +477,9 @@ def begin_create_or_update( :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 + :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -426,22 +488,25 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, + job_agent_name: str, + private_endpoint_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Required. + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -454,9 +519,9 @@ def begin_create_or_update( :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 + :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -465,22 +530,25 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], + job_agent_name: str, + private_endpoint_name: str, + parameters: Union[_models.JobPrivateEndpoint, IO], **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + ) -> LROPoller[_models.JobPrivateEndpoint]: + """Creates or updates a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_name: str - :param parameters: The required parameters for creating a server communication link. Is either - a ServerCommunicationLink type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.ServerCommunicationLink or IO + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint. Required. + :type private_endpoint_name: str + :param parameters: The requested private endpoint state. Is either a JobPrivateEndpoint type or + a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.JobPrivateEndpoint or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -492,17 +560,17 @@ def begin_create_or_update( :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 + :return: An instance of LROPoller that returns either JobPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.JobPrivateEndpoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerCommunicationLink] = kwargs.pop("cls", None) + cls: ClsType[_models.JobPrivateEndpoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -510,7 +578,8 @@ def begin_create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, parameters=parameters, api_version=api_version, content_type=content_type, @@ -522,13 +591,15 @@ def begin_create_or_update( kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + deserialized = self._deserialize("JobPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -543,86 +614,128 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 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_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerCommunicationLink"]: - """Gets a list of server communication links. + def begin_delete( + self, resource_group_name: str, server_name: str, job_agent_name: str, private_endpoint_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint. :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. Required. :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param private_endpoint_name: The name of the private endpoint to delete. Required. + :type private_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerCommunicationLink] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServerCommunicationLinkListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + job_agent_name=job_agent_name, + private_endpoint_name=private_endpoint_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("ServerCommunicationLinkListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return cls(pipeline_response, None, {}) - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **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) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/privateEndpoints/{privateEndpointName}" } 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 0d964af025e4..216cf84fb819 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -56,7 +57,7 @@ def build_list_by_job_execution_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +112,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -216,7 +217,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -253,7 +254,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -329,7 +341,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) request = build_get_request( 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 8f2f0faa6177..9885da75dddd 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,32 +37,25 @@ _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 +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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps", ) # pylint: disable=line-too-long 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"), } @@ -76,12 +70,11 @@ def build_list_by_version_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_by_version_request( +def build_get_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 @@ -89,20 +82,19 @@ def build_get_by_version_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", ) # pylint: disable=line-too-long 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"), } @@ -118,25 +110,33 @@ def build_get_by_version_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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 +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, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}", ) # pylint: disable=line-too-long 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"), } @@ -146,12 +146,14 @@ def build_list_by_job_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_delete_request( resource_group_name: str, server_name: str, job_agent_name: str, @@ -160,12 +162,9 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -185,39 +184,35 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_create_or_update_request( +def build_list_by_version_request( resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, - step_name: str, + job_version: int, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps", ) # pylint: disable=line-too-long 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"), + "jobVersion": _SERIALIZER.url("job_version", job_version, "int"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -227,35 +222,38 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps/{stepName}", ) # pylint: disable=line-too-long 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"), } @@ -265,7 +263,10 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class JobStepsOperations: @@ -287,184 +288,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_version( - self, - resource_group_name: str, - server_name: str, - job_agent_name: str, - job_name: str, - job_version: int, - **kwargs: Any - ) -> Iterable["_models.JobStep"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param job_version: The version of the job to get. Required. - :type job_version: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobStep or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_version.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_version.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps" - } - - @distributed_trace - def get_by_version( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job. Required. - :type job_name: str - :param job_version: The version of the job to get. Required. - :type job_version: int - :param step_name: The name of the job step. Required. - :type step_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobStep or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobStep - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get_by_version.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("JobStep", pipeline_response) - - if cls: - 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}" - } - @distributed_trace def list_by_job( self, resource_group_name: str, server_name: str, job_agent_name: str, job_name: str, **kwargs: Any @@ -488,7 +311,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) error_map = { @@ -517,7 +340,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -590,7 +424,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) request = build_get_request( @@ -750,7 +584,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) @@ -845,7 +679,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -880,3 +714,192 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/steps/{stepName}" } + + @distributed_trace + def list_by_version( + self, + resource_group_name: str, + server_name: str, + job_agent_name: str, + job_name: str, + job_version: int, + **kwargs: Any + ) -> Iterable["_models.JobStep"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param job_version: The version of the job to get. Required. + :type job_version: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobStep or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.JobStep] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobStepListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_version.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_version.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/versions/{jobVersion}/steps" + } + + @distributed_trace + def get_by_version( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job. Required. + :type job_name: str + :param job_version: The version of the job to get. Required. + :type job_version: int + :param step_name: The name of the job step. Required. + :type step_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobStep or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobStep + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobStep] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get_by_version.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("JobStep", pipeline_response) + + if cls: + 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}" + } 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 722a3c77fe3d..941561184a48 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import datetime from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,12 +37,13 @@ _SERIALIZER.client_side_validation = False -def build_list_by_job_execution_request( +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, @@ -56,13 +58,13 @@ def build_list_by_job_execution_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -70,6 +72,7 @@ def build_list_by_job_execution_request( "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"), } @@ -98,34 +101,27 @@ def build_list_by_job_execution_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_step_request( +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, - *, - 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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets/{targetId}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -134,26 +130,13 @@ def build_list_by_step_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if create_time_min is not None: - _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") - if create_time_max is not None: - _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") - if end_time_min is not None: - _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") - if end_time_max is not None: - _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") - if is_active is not None: - _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") - if skip is not None: - _params["$skip"] = _SERIALIZER.query("skip", skip, "int") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -162,27 +145,33 @@ def build_list_by_step_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +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, - step_name: str, - target_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -190,14 +179,26 @@ def build_get_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if create_time_min is not None: + _params["createTimeMin"] = _SERIALIZER.query("create_time_min", create_time_min, "iso-8601") + if create_time_max is not None: + _params["createTimeMax"] = _SERIALIZER.query("create_time_max", create_time_max, "iso-8601") + if end_time_min is not None: + _params["endTimeMin"] = _SERIALIZER.query("end_time_min", end_time_min, "iso-8601") + if end_time_max is not None: + _params["endTimeMax"] = _SERIALIZER.query("end_time_max", end_time_max, "iso-8601") + if is_active is not None: + _params["isActive"] = _SERIALIZER.query("is_active", is_active, "bool") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -226,13 +227,14 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_job_execution( + def list_by_step( self, 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, @@ -242,7 +244,7 @@ def list_by_job_execution( top: Optional[int] = None, **kwargs: Any ) -> Iterable["_models.JobExecution"]: - """Lists target executions for all steps of a job execution. + """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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -255,6 +257,8 @@ def list_by_job_execution( :type job_name: str :param job_execution_id: The id of the job execution. Required. :type job_execution_id: str + :param step_name: The name of the step. Required. + :type step_name: str :param create_time_min: If specified, only job executions created at or after the specified time are included. Default value is None. :type create_time_min: ~datetime.datetime @@ -282,7 +286,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -296,12 +300,13 @@ def list_by_job_execution( def prepare_request(next_link=None): if not next_link: - request = build_list_by_job_execution_request( + 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, @@ -311,7 +316,7 @@ def prepare_request(next_link=None): skip=skip, top=top, api_version=api_version, - template_url=self.list_by_job_execution.metadata["url"], + template_url=self.list_by_step.metadata["url"], headers=_headers, params=_params, ) @@ -319,7 +324,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -349,12 +365,12 @@ def get_next(next_link=None): 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" + list_by_step.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/steps/{stepName}/targets" } @distributed_trace - def list_by_step( + def get( self, resource_group_name: str, server_name: str, @@ -362,6 +378,92 @@ def list_by_step( 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param job_agent_name: The name of the job agent. Required. + :type job_agent_name: str + :param job_name: The name of the job to get. Required. + :type job_name: str + :param job_execution_id: The unique id of the job execution. Required. + :type job_execution_id: str + :param step_name: The name of the step. Required. + :type step_name: str + :param target_id: The target id. Required. + :type target_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobExecution or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.JobExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("JobExecution", pipeline_response) + + if cls: + 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}" + } + + @distributed_trace + def list_by_job_execution( + self, + 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, @@ -371,7 +473,7 @@ def list_by_step( top: Optional[int] = None, **kwargs: Any ) -> Iterable["_models.JobExecution"]: - """Lists the target executions of a job step execution. + """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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -384,8 +486,6 @@ def list_by_step( :type job_name: str :param job_execution_id: The id of the job execution. Required. :type job_execution_id: str - :param step_name: The name of the step. Required. - :type step_name: str :param create_time_min: If specified, only job executions created at or after the specified time are included. Default value is None. :type create_time_min: ~datetime.datetime @@ -413,7 +513,7 @@ def list_by_step( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobExecutionListResult] = kwargs.pop("cls", None) error_map = { @@ -427,13 +527,12 @@ def list_by_step( def prepare_request(next_link=None): if not next_link: - request = build_list_by_step_request( + 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, - step_name=step_name, subscription_id=self._config.subscription_id, create_time_min=create_time_min, create_time_max=create_time_max, @@ -443,7 +542,7 @@ def prepare_request(next_link=None): skip=skip, top=top, api_version=api_version, - template_url=self.list_by_step.metadata["url"], + template_url=self.list_by_job_execution.metadata["url"], headers=_headers, params=_params, ) @@ -451,7 +550,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -481,93 +591,6 @@ def get_next(next_link=None): 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" - } - - @distributed_trace - def get( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param job_agent_name: The name of the job agent. Required. - :type job_agent_name: str - :param job_name: The name of the job to get. Required. - :type job_name: str - :param job_execution_id: The unique id of the job execution. Required. - :type job_execution_id: str - :param step_name: The name of the step. Required. - :type step_name: str - :param target_id: The target id. Required. - :type target_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JobExecution or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.JobExecution - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.JobExecution] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("JobExecution", pipeline_response) - - if cls: - 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}" + list_by_job_execution.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}/targets" } 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 066f86f77095..12b40963ff34 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_agent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -219,7 +220,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobTargetGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -247,7 +248,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -312,7 +324,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -462,7 +474,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobTargetGroup] = kwargs.pop("cls", None) @@ -548,7 +560,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 fb2db230a19b..292dfea6ed2d 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +81,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +151,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobVersionListResult] = kwargs.pop("cls", None) error_map = { @@ -179,7 +180,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -252,7 +264,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobVersion] = kwargs.pop("cls", None) request = build_get_request( 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 a0dd80bce5f7..07887d5d5d13 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_agent_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +75,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +143,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -204,7 +205,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobListResult] = kwargs.pop("cls", None) error_map = { @@ -232,7 +233,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -297,7 +309,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) request = build_get_request( @@ -446,7 +458,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Job] = kwargs.pop("cls", None) @@ -532,7 +544,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 1b0a2f056438..835c011dab21 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads", ) # pylint: disable=line-too-long 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"), } @@ -76,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -87,8 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,31 +104,36 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + ledger_digest_uploads: Union[str, _models.LedgerDigestUploadsName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}", ) # pylint: disable=line-too-long 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"), } @@ -144,9 +143,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_disable_request( @@ -160,7 +161,7 @@ def build_disable_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -206,6 +207,100 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.LedgerDigestUploads"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 LedgerDigestUploads or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads" + } + @distributed_trace def get( self, @@ -242,7 +337,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) request = build_get_request( @@ -301,7 +396,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) @@ -483,7 +578,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -530,89 +625,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads/{ledgerDigestUploads}" } - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.LedgerDigestUploads"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 LedgerDigestUploads or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LedgerDigestUploads] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.LedgerDigestUploadsListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/ledgerDigestUploads" - } - def _disable_initial( self, resource_group_name: str, @@ -632,7 +644,7 @@ def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.LedgerDigestUploads]] = kwargs.pop("cls", None) request = build_disable_request( @@ -710,7 +722,7 @@ def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 21c118b4430c..b6b5522496ad 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,70 +39,112 @@ _SERIALIZER.client_side_validation = False -def build_copy_request( +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_server_request( location_name: str, long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_list_by_database_request( location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", ) # pylint: disable=line-too-long path_format_arguments = { "locationName": _SERIALIZER.url("location_name", location_name, "str"), @@ -111,21 +154,24 @@ def build_update_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -139,7 +185,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +226,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -206,26 +252,25 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_by_database_request( +def build_change_access_tier_request( location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier", ) # pylint: disable=line-too-long path_format_arguments = { "locationName": _SERIALIZER.url("location_name", location_name, "str"), @@ -235,92 +280,136 @@ def build_list_by_database_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_location_request( +def build_copy_request( location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( +def build_update_request( location_name: str, long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", + ) # pylint: disable=line-too-long + 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"), } @@ -341,26 +430,26 @@ def build_list_by_server_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_copy_by_resource_group_request( +def build_list_by_resource_group_server_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, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -368,46 +457,47 @@ def build_copy_by_resource_group_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_by_resource_group_request( +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, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -418,21 +508,24 @@ def build_update_by_resource_group_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_resource_group_request( @@ -447,7 +540,7 @@ def build_get_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -490,7 +583,7 @@ def build_delete_by_resource_group_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -517,27 +610,26 @@ def build_delete_by_resource_group_request( return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_by_resource_group_database_request( +def build_change_access_tier_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, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -548,89 +640,90 @@ def build_list_by_resource_group_database_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_location_request( +def build_copy_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, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy", ) # pylint: disable=line-too-long 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"), + "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_server_request( +def build_update_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, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -638,27 +731,27 @@ def build_list_by_resource_group_server_request( "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class LongTermRetentionBackupsOperations: +class LongTermRetentionBackupsOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. @@ -677,15 +770,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _copy_initial( + @distributed_trace + def list_by_location( self, location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> Iterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location. + + :param location_name: The location of the database. Required. + :type location_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -694,157 +808,183 @@ def _copy_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + 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, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_copy_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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._copy_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - _copy_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + list_by_location.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" } - @overload - def begin_copy( + @distributed_trace + def list_by_server( self, location_name: str, long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: _models.CopyLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + ) -> Iterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given server. :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_copy( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace - def begin_copy( - self, + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + } + + @distributed_trace + def list_by_database( + self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup. + ) -> Iterable["_models.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database. :param location_name: The location of the database. Required. :type location_name: str @@ -852,87 +992,120 @@ def begin_copy( :type long_term_retention_server_name: str :param long_term_retention_database_name: The name of the database. Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._copy_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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_copy.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" } - def _update_initial( + @distributed_trace + def get( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> _models.LongTermRetentionBackup: + """Gets a long term retention backup. + + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LongTermRetentionBackup or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -941,32 +1114,20 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - request = build_update_request( + 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, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -980,118 +1141,85 @@ def _update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: 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" + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - @overload - def begin_update( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: _models.UpdateLongTermRetentionBackupParameters, - *, - content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def begin_update( - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_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, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + } @distributed_trace - def begin_update( + def begin_delete( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> LROPoller[None]: + """Deletes a long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -1101,12 +1229,6 @@ def begin_update( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -1115,30 +1237,25 @@ def begin_update( :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] + :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._delete_initial( # type: ignore 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, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1146,11 +1263,9 @@ def begin_update( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1167,34 +1282,19 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - @distributed_trace - def get( + def _change_access_tier_initial( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> _models.LongTermRetentionBackup: - """Gets a long term retention backup. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.LongTermRetentionBackup - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> Optional[_models.LongTermRetentionBackup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1203,20 +1303,32 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) - request = build_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ChangeLongTermRetentionBackupAccessTierParameters") + + request = build_change_access_tier_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, api_version=api_version, - template_url=self.get.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._change_access_tier_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1230,94 +1342,51 @@ def get( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_delete_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, - api_version=api_version, - template_url=self._delete_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + _change_access_tier_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } - @distributed_trace - def begin_delete( + @overload + def begin_change_access_tier( self, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Deletes a long term retention backup. + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. + :param long_term_retention_database_name: Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. + :param backup_name: Required. :type backup_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1326,25 +1395,111 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + @overload + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param location_name: Required. + :type location_name: str + :param long_term_retention_server_name: Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: Required. + :type long_term_retention_database_name: str + :param backup_name: Required. + :type backup_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_change_access_tier( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. + + :param location_name: Required. + :type location_name: str + :param long_term_retention_server_name: Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: Required. + :type long_term_retention_database_name: str + :param backup_name: Required. + :type backup_name: str + :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a IO + type. Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._change_access_tier_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, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1352,9 +1507,11 @@ def begin_delete( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1371,46 +1528,19 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + begin_change_access_tier.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } - @distributed_trace - def list_by_database( + def _copy_initial( self, 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, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. - - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1419,249 +1549,243 @@ def list_by_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") - def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + request = build_copy_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._copy_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_next(next_link=None): - request = prepare_request(next_link) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, {}) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + return deserialized + + _copy_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace - def list_by_location( + @overload + def begin_copy( self, location_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.CopyLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + @overload + def begin_copy( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/longTermRetentionBackups" - } + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_by_server( + def begin_copy( self, location_name: str, long_term_retention_server_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Is either a + CopyLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._copy_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, deserialized, {}) + return deserialized - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - 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) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + begin_copy.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - def _copy_by_resource_group_initial( + def _update_initial( self, - resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { @@ -1675,7 +1799,7 @@ def _copy_by_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) @@ -1685,10 +1809,9 @@ def _copy_by_resource_group_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - request = build_copy_by_resource_group_request( - resource_group_name=resource_group_name, + request = build_update_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, @@ -1698,7 +1821,7 @@ def _copy_by_resource_group_initial( content_type=content_type, json=_json, content=_content, - template_url=self._copy_by_resource_group_initial.metadata["url"], + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1725,28 +1848,24 @@ def _copy_by_resource_group_initial( 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" + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } @overload - def begin_copy_by_resource_group( + def begin_update( self, - 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, + parameters: _models.UpdateLongTermRetentionBackupParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + """Updates an existing long term retention backup. - :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. Required. - :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. @@ -1755,8 +1874,8 @@ def begin_copy_by_resource_group( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1776,9 +1895,8 @@ def begin_copy_by_resource_group( """ @overload - def begin_copy_by_resource_group( + def begin_update( self, - resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, @@ -1788,11 +1906,8 @@ def begin_copy_by_resource_group( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + """Updates an existing long term retention backup. - :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. Required. - :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. @@ -1801,7 +1916,7 @@ def begin_copy_by_resource_group( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Required. + :param parameters: The requested backup resource state. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1822,21 +1937,17 @@ def begin_copy_by_resource_group( """ @distributed_trace - def begin_copy_by_resource_group( + def begin_update( self, - resource_group_name: str, location_name: str, long_term_retention_server_name: str, long_term_retention_database_name: str, backup_name: str, - parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. + """Updates an existing long term retention backup. - :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. Required. - :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str :param long_term_retention_server_name: The name of the server. Required. @@ -1845,9 +1956,9 @@ def begin_copy_by_resource_group( :type long_term_retention_database_name: str :param backup_name: The backup name. Required. :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO + :param parameters: The requested backup resource state. Is either a + UpdateLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1868,15 +1979,14 @@ def begin_copy_by_resource_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._copy_by_resource_group_initial( - resource_group_name=resource_group_name, + raw_result = self._update_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, @@ -1912,20 +2022,44 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_copy_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } - def _update_by_resource_group_initial( + @distributed_trace + def list_by_resource_group_location( self, resource_group_name: str, location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + ) -> Iterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given location based on 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. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1934,77 +2068,80 @@ def _update_by_resource_group_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + 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, + api_version=api_version, + template_url=self.list_by_resource_group_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_update_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, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_by_resource_group_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - _update_by_resource_group_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + list_by_resource_group_location.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" } - @overload - def begin_update_by_resource_group( + @distributed_trace + def list_by_resource_group_server( self, 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, - *, - content_type: str = "application/json", + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + ) -> Iterable["_models.LongTermRetentionBackup"]: + """Lists the long term retention backups for a given server based on resource groups. :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. Required. @@ -2013,88 +2150,108 @@ def begin_update_by_resource_group( :type location_name: str :param long_term_retention_server_name: The name of the server. Required. :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - :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. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @distributed_trace - def begin_update_by_resource_group( - self, - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - long_term_retention_database_name: str, - backup_name: str, - parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], - **kwargs: Any - ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_resource_group_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_resource_group_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + } + + @distributed_trace + def list_by_resource_group_database( + self, + 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.LongTermRetentionBackup"]: + """Lists all long term retention backups for a database based on a particular 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. Required. @@ -2105,77 +2262,95 @@ def begin_update_by_resource_group( :type long_term_retention_server_name: str :param long_term_retention_database_name: The name of the database. Required. :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The requested backup resource state. Is either a - UpdateLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or - the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :return: An iterator like instance of either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_by_resource_group_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, - parameters=parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_resource_group_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_update_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + 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_resource_group_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" } @distributed_trace @@ -2217,7 +2392,7 @@ def get_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) request = build_get_by_resource_group_request( @@ -2277,7 +2452,7 @@ def _delete_by_resource_group_initial( # pylint: disable=inconsistent-return-st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_resource_group_request( @@ -2351,7 +2526,7 @@ def begin_delete_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2394,46 +2569,16 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } - @distributed_trace - def list_by_resource_group_database( + def _change_access_tier_by_resource_group_initial( self, 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, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 LongTermRetentionBackup or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - + ) -> Optional[_models.LongTermRetentionBackup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2442,248 +2587,769 @@ def list_by_resource_group_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackup]] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ChangeLongTermRetentionBackupAccessTierParameters") - def get_next(next_link=None): - request = prepare_request(next_link) + request = build_change_access_tier_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._change_access_tier_by_resource_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - 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) + response = pipeline_response.http_response - return pipeline_response + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return ItemPaged(get_next, extract_data) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) - list_by_resource_group_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups" + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _change_access_tier_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" } - @distributed_trace - def list_by_resource_group_location( + @overload + def begin_change_access_tier_by_resource_group( self, resource_group_name: str, location_name: str, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: _models.ChangeLongTermRetentionBackupAccessTierParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. :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. Required. :type resource_group_name: str - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_server_name: Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: Required. + :type long_term_retention_database_name: str + :param backup_name: Required. + :type backup_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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) + @overload + def begin_change_access_tier_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. - list_by_resource_group_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" - } + :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. Required. + :type resource_group_name: str + :param location_name: Required. + :type location_name: str + :param long_term_retention_server_name: Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: Required. + :type long_term_retention_database_name: str + :param backup_name: Required. + :type backup_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_by_resource_group_server( + def begin_change_access_tier_by_resource_group( self, 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, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.ChangeLongTermRetentionBackupAccessTierParameters, IO], **kwargs: Any - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. + ) -> LROPoller[_models.LongTermRetentionBackup]: + """Change a long term retention backup access tier. :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. Required. :type resource_group_name: str - :param location_name: The location of the database. Required. + :param location_name: Required. :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. + :param long_term_retention_server_name: Required. :type long_term_retention_server_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param long_term_retention_database_name: Required. + :type long_term_retention_database_name: str + :param backup_name: Required. + :type backup_name: str + :param parameters: Is either a ChangeLongTermRetentionBackupAccessTierParameters type or a IO + type. Required. + :type parameters: ~azure.mgmt.sql.models.ChangeLongTermRetentionBackupAccessTierParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LongTermRetentionBackup or the result of + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionBackup] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.LongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._change_access_tier_by_resource_group_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - def prepare_request(next_link=None): - if not next_link: + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - 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, - api_version=api_version, - template_url=self.list_by_resource_group_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_change_access_tier_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/changeAccessTier" + } + + def _copy_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") + + request = build_copy_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._copy_by_resource_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + + if cls: + 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" + } + + @overload + def begin_copy_by_resource_group( + self, + 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, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_copy_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The parameters needed for long term retention copy request. Is either a + CopyLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._copy_by_resource_group_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_copy_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + } + + def _update_by_resource_group_initial( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.LongTermRetentionBackupOperationResult]] = kwargs.pop("cls", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("LongTermRetentionBackupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") - def get_next(next_link=None): - request = prepare_request(next_link) + request = build_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_by_resource_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - 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) + response = pipeline_response.http_response - return pipeline_response + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return ItemPaged(get_next, extract_data) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) - list_by_resource_group_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" + if cls: + 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" + } + + @overload + def begin_update_by_resource_group( + self, + 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, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is either a + UpdateLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either LongTermRetentionBackupOperationResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LongTermRetentionBackupOperationResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_by_resource_group_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, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("LongTermRetentionBackupOperationResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } 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 5f8a467b2938..04fb2236e615 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -37,36 +38,48 @@ _SERIALIZER.client_side_validation = False -def build_get_request( +def build_list_by_location_request( location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -75,75 +88,81 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_list_by_database_request( location_name: str, managed_instance_name: str, database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( + +def build_get_request( location_name: str, managed_instance_name: str, database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -152,51 +171,41 @@ def build_list_by_database_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_instance_request( +def build_delete_request( location_name: str, managed_instance_name: str, + database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_by_location_request( +def build_list_by_instance_request( location_name: str, + managed_instance_name: str, subscription_id: str, *, only_latest_per_database: Optional[bool] = None, @@ -206,16 +215,17 @@ def build_list_by_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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"), } @@ -236,38 +246,50 @@ def build_list_by_location_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_by_resource_group_request( +def build_list_by_resource_group_location_request( resource_group_name: str, location_name: str, - managed_instance_name: str, - database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -276,79 +298,85 @@ def build_get_by_resource_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_by_resource_group_request( +def build_list_by_resource_group_database_request( resource_group_name: str, location_name: str, managed_instance_name: str, database_name: str, - backup_name: str, subscription_id: str, + *, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if only_latest_per_database is not None: + _params["onlyLatestPerDatabase"] = _SERIALIZER.query( + "only_latest_per_database", only_latest_per_database, "bool" + ) + if database_state is not None: + _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_database_request( + +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, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -357,54 +385,44 @@ def build_list_by_resource_group_database_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_instance_request( +def build_delete_by_resource_group_request( resource_group_name: str, location_name: str, managed_instance_name: str, + database_name: str, + backup_name: str, subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}", ) # pylint: disable=line-too-long 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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if only_latest_per_database is not None: - _params["onlyLatestPerDatabase"] = _SERIALIZER.query( - "only_latest_per_database", only_latest_per_database, "bool" - ) - if database_state is not None: - _params["databaseState"] = _SERIALIZER.query("database_state", database_state, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_by_resource_group_location_request( +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, @@ -414,17 +432,18 @@ def build_list_by_resource_group_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups", ) # pylint: disable=line-too-long 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"), } @@ -464,6 +483,229 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_location( + self, + location_name: str, + only_latest_per_database: Optional[bool] = None, + database_state: Optional[Union[str, _models.DatabaseState]] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackup"]: + """Lists the long term retention backups for managed databases in a given location. + + :param location_name: The location of the database. Required. + :type location_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :type top: int + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 ManagedInstanceLongTermRetentionBackup or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + skip=skip, + top=top, + filter=filter, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/longTermRetentionManagedInstanceBackups" + } + + @distributed_trace + def list_by_database( + self, + 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.ManagedInstanceLongTermRetentionBackup"]: + """Lists all long term retention backups for a managed database. + + :param location_name: The location of the database. Required. + :type location_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database. Required. + :type database_name: str + :param only_latest_per_database: Whether or not to only get the latest backup for each + database. Default value is None. + :type only_latest_per_database: bool + :param database_state: Whether to query against just live databases, just deleted databases, or + all databases. Known values are: "All", "Live", and "Deleted". Default value is None. + :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 ManagedInstanceLongTermRetentionBackup or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + } + @distributed_trace def get( self, location_name: str, managed_instance_name: str, database_name: str, backup_name: str, **kwargs: Any @@ -494,7 +736,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) request = build_get_request( @@ -547,7 +789,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -611,7 +853,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -654,23 +896,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- } @distributed_trace - def list_by_database( + def list_by_instance( self, 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.ManagedInstanceLongTermRetentionBackup"]: - """Lists all long term retention backups for a managed database. + """Lists the long term retention backups for a given managed instance. :param location_name: The location of the database. Required. :type location_name: str :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str - :param database_name: The name of the managed database. Required. - :type database_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -687,7 +926,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -701,15 +940,14 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + request = build_list_by_instance_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, api_version=api_version, - template_url=self.list_by_database.metadata["url"], + template_url=self.list_by_instance.metadata["url"], headers=_headers, params=_params, ) @@ -717,7 +955,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -747,31 +996,42 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" } @distributed_trace - def list_by_instance( + def list_by_resource_group_location( self, + 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, + skip: Optional[int] = None, + top: Optional[int] = None, + filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for a given managed instance. + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool :param database_state: Whether to query against just live databases, just deleted databases, or all databases. Known values are: "All", "Live", and "Deleted". Default value is None. :type database_state: str or ~azure.mgmt.sql.models.DatabaseState + :param skip: The number of elements in the collection to skip. Default value is None. + :type skip: int + :param top: The number of elements to return from the collection. Default value is None. + :type top: int + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 ManagedInstanceLongTermRetentionBackup or the result of cls(response) @@ -782,7 +1042,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -796,14 +1056,17 @@ def list_by_instance( def prepare_request(next_link=None): if not next_link: - request = build_list_by_instance_request( + request = build_list_by_resource_group_location_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, + skip=skip, + top=top, + filter=filter, api_version=api_version, - template_url=self.list_by_instance.metadata["url"], + template_url=self.list_by_resource_group_location.metadata["url"], headers=_headers, params=_params, ) @@ -811,7 +1074,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -841,22 +1115,32 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" + list_by_resource_group_location.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" } @distributed_trace - def list_by_location( + def list_by_resource_group_database( self, + 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.ManagedInstanceLongTermRetentionBackup"]: - """Lists the long term retention backups for managed databases in a given location. + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str :param location_name: The location of the database. Required. :type location_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database. Required. + :type database_name: str :param only_latest_per_database: Whether or not to only get the latest backup for each database. Default value is None. :type only_latest_per_database: bool @@ -873,7 +1157,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -887,13 +1171,16 @@ def list_by_location( def prepare_request(next_link=None): if not next_link: - request = build_list_by_location_request( + 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, api_version=api_version, - template_url=self.list_by_location.metadata["url"], + template_url=self.list_by_resource_group_database.metadata["url"], headers=_headers, params=_params, ) @@ -901,7 +1188,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -931,8 +1229,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_location.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" + list_by_resource_group_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" } @distributed_trace @@ -974,7 +1272,7 @@ def get_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackup] = kwargs.pop("cls", None) request = build_get_by_resource_group_request( @@ -1034,7 +1332,7 @@ def _delete_by_resource_group_initial( # pylint: disable=inconsistent-return-st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_resource_group_request( @@ -1108,7 +1406,7 @@ def begin_delete_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1151,109 +1449,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}" } - @distributed_trace - def list_by_resource_group_database( - self, - 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.ManagedInstanceLongTermRetentionBackup"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database. Required. - :type database_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups" - } - @distributed_trace def list_by_resource_group_instance( self, @@ -1289,7 +1484,7 @@ def list_by_resource_group_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) error_map = { @@ -1319,7 +1514,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1352,98 +1558,3 @@ def get_next(next_link=None): list_by_resource_group_instance.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups" } - - @distributed_trace - def list_by_resource_group_location( - self, - 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.ManagedInstanceLongTermRetentionBackup"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param only_latest_per_database: Whether or not to only get the latest backup for each - database. Default value is None. - :type only_latest_per_database: bool - :param database_state: Whether to query against just live databases, just deleted databases, or - all databases. Known values are: "All", "Live", and "Deleted". Default value is None. - :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 ManagedInstanceLongTermRetentionBackup or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionBackup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionBackupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_resource_group_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_resource_group_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups" - } 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 c6c27297dabf..ee1d1168455d 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies", ) # pylint: disable=line-too-long 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"), } @@ -76,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -87,8 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,31 +104,36 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + database_name: str, + policy_name: Union[str, _models.LongTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", ) # pylint: disable=line-too-long 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"), } @@ -144,9 +143,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class LongTermRetentionPoliciesOperations: @@ -168,6 +169,101 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 LongTermRetentionPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies" + } + @distributed_trace def get( self, @@ -204,7 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -263,7 +359,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LongTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -443,7 +539,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LongTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -489,87 +585,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 LongTermRetentionPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.LongTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/backupLongTermRetentionPolicies" - } 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 ba4ffe3fc60e..83b637557d3b 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 @@ -46,7 +46,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +131,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) request = build_get_request( 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 66edcd575740..7ab6e134d61d 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 @@ -47,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +86,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -168,7 +168,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) request = build_get_request( @@ -317,7 +317,7 @@ def create_or_update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 750aed175679..b17cd61d94ff 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -76,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -87,8 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,14 +104,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -128,7 +120,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -155,27 +147,34 @@ def build_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_update_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedShortTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -185,9 +184,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class ManagedBackupShortTermRetentionPoliciesOperations: @@ -209,6 +210,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :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 ManagedBackupShortTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies" + } + @distributed_trace def get( self, @@ -245,7 +342,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -304,7 +401,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -487,7 +584,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -554,7 +651,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -737,7 +834,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -783,88 +880,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :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 ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupShortTermRetentionPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py index cd5a454554cf..9a2884829ef9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +120,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -193,7 +194,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -221,7 +222,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -293,7 +305,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -449,7 +461,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabaseAdvancedThreatProtection] = kwargs.pop("cls", None) 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 60f14fdd8205..8f1973c78450 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -51,7 +52,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +102,7 @@ def build_list_by_table_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -144,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +234,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -266,7 +267,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -335,7 +347,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumnListResult] = kwargs.pop("cls", None) error_map = { @@ -366,7 +378,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -442,7 +465,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseColumn] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py index f57e78fde7fb..5de1125ac7d8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_database_move_operations_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_location_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +161,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseMoveOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -189,7 +190,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -252,7 +264,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseMoveOperationResult] = kwargs.pop("cls", None) request = build_get_request( 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 7c8b7fca22c9..b6f7d5cf77d9 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -46,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +89,7 @@ def build_list_by_query_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +172,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceQuery] = kwargs.pop("cls", None) request = build_get_request( @@ -248,7 +249,7 @@ def list_by_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceQueryStatistics] = kwargs.pop("cls", None) error_map = { @@ -280,7 +281,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 386bb585a9d2..7ef4a4fb3572 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 @@ -41,7 +41,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -188,7 +188,7 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 3c4950f713ff..6c1be077a67f 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 @@ -45,7 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +127,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseRestoreDetailsResult] = kwargs.pop("cls", None) request = build_get_request( 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 d52d4004cf35..1e02fd56f2d2 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +48,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +162,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchemaListResult] = kwargs.pop("cls", None) error_map = { @@ -190,7 +191,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -255,7 +267,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSchema] = kwargs.pop("cls", None) request = build_get_request( 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 7778c191542c..679215549cf4 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,30 +37,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -74,7 +69,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -85,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,31 +102,36 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +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, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -142,9 +141,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ManagedDatabaseSecurityAlertPoliciesOperations: @@ -166,6 +167,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedDatabaseSecurityAlertPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database for which the security alert policies + are defined. Required. + :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 ManagedDatabaseSecurityAlertPolicy or the result + of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies" + } + @distributed_trace def get( self, @@ -185,7 +282,7 @@ def get( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedDatabaseSecurityAlertPolicy or the result of cls(response) @@ -203,7 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -264,7 +361,7 @@ def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy @@ -299,7 +396,7 @@ def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Required. :type parameters: IO @@ -332,7 +429,7 @@ def create_or_update( :param database_name: The name of the managed database for which the security alert policy is defined. Required. :type database_name: str - :param security_alert_policy_name: The name of the security alert policy. "Default" Required. + :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName :param parameters: The database security alert policy. Is either a ManagedDatabaseSecurityAlertPolicy type or a IO type. Required. @@ -356,7 +453,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicy] = kwargs.pop("cls", None) @@ -410,88 +507,3 @@ def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedDatabaseSecurityAlertPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database for which the security alert policies - are defined. Required. - :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 ManagedDatabaseSecurityAlertPolicy or the result - of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedDatabaseSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedDatabaseSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies" - } 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 febe6099c381..01bff58d48b7 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -50,7 +51,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +144,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityEventCollection] = kwargs.pop("cls", None) error_map = { @@ -175,7 +176,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 387c1e70b538..b26bec881b49 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,42 +42,44 @@ _SERIALIZER.client_side_validation = False -def build_get_request( +def build_list_current_by_database_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, + *, + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if count is not None: + _params["$count"] = _SERIALIZER.query("count", count, "bool") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -85,67 +88,103 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_update_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_recommended_by_database_request( resource_group_name: str, managed_instance_name: str, database_name: str, - schema_name: str, - table_name: str, - column_name: str, subscription_id: str, + *, + skip_token: Optional[str] = None, + include_disabled_recommendations: Optional[bool] = None, + filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if include_disabled_recommendations is not None: + _params["includeDisabledRecommendations"] = _SERIALIZER.query( + "include_disabled_recommendations", include_disabled_recommendations, "bool" + ) + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -167,10 +206,13 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disable_recommendation_request( + +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -180,14 +222,18 @@ def build_disable_recommendation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("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}/disable", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -205,10 +251,15 @@ def build_disable_recommendation_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_enable_recommendation_request( +def build_delete_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -220,12 +271,12 @@ def build_enable_recommendation_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -243,72 +294,74 @@ def build_enable_recommendation_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_current_by_database_request( +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, - *, - skip_token: Optional[str] = None, - count: Optional[bool] = None, - filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "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: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - if count is not None: - _params["$count"] = _SERIALIZER.query("count", count, "bool") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_update_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "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"), } @@ -317,34 +370,28 @@ def build_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_list_recommended_by_database_request( +def build_list_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/sensitivityLabels", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -356,12 +403,6 @@ def build_list_recommended_by_database_request( _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if skip_token is not None: - _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") - if include_disabled_recommendations is not None: - _params["includeDisabledRecommendations"] = _SERIALIZER.query( - "include_disabled_recommendations", include_disabled_recommendations, "bool" - ) if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -392,18 +433,17 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( + def list_current_by_database( self, 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], + skip_token: Optional[str] = None, + count: Optional[bool] = None, + filter: Optional[str] = None, **kwargs: Any - ) -> _models.SensitivityLabel: - """Gets the sensitivity label of a given column. + ) -> Iterable["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -412,20 +452,24 @@ def get( :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :param sensitivity_label_source: The source of the sensitivity label. Known values are: - "current" and "recommended". Required. - :type sensitivity_label_source: str or ~azure.mgmt.sql.models.SensitivityLabelSource + :param skip_token: Default value is None. + :type skip_token: str + :param count: Default value is None. + :type count: bool + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :return: An iterator like instance of either SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -434,25 +478,392 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_current_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_current_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + } + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: _models.SensitivityLabelUpdateList, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, IO], + **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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param parameters: Is either a SensitivityLabelUpdateList type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + } + + @distributed_trace + def list_recommended_by_database( + self, + 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.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param skip_token: Default value is None. + :type skip_token: str + :param include_disabled_recommendations: Specifies whether to include disabled recommendations + or not. Default value is None. + :type include_disabled_recommendations: bool + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_recommended_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_recommended_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + } + + @distributed_trace + def get( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :param sensitivity_label_source: The source of the sensitivity label. Known values are: + "current" and "recommended". Required. + :type sensitivity_label_source: str or ~azure.mgmt.sql.models.SensitivityLabelSource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SensitivityLabel or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) @@ -618,7 +1029,7 @@ def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) @@ -677,91 +1088,7 @@ def create_or_update( } @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param schema_name: The name of the schema. Required. - :type schema_name: str - :param table_name: The name of the table. Required. - :type table_name: str - :param column_name: The name of the column. Required. - :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - template_url=self.delete.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } - - @distributed_trace - def disable_recommendation( # pylint: disable=inconsistent-return-statements + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, @@ -771,7 +1098,7 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements column_name: str, **kwargs: Any ) -> None: - """Disables sensitivity recommendations on a given column. + """Deletes the sensitivity label of a given column. :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. Required. @@ -786,8 +1113,8 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. + :keyword sensitivity_label_source: The source of the sensitivity label. Default value is + "current". Note that overriding this default value may result in unsupported behavior. :paramtype sensitivity_label_source: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -805,11 +1132,11 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_recommendation_request( + request = build_delete_request( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, database_name=database_name, @@ -819,7 +1146,7 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - template_url=self.disable_recommendation.metadata["url"], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -840,12 +1167,12 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" } @distributed_trace - def enable_recommendation( # pylint: disable=inconsistent-return-statements + def disable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, @@ -855,8 +1182,7 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements column_name: str, **kwargs: Any ) -> None: - """Enables sensitivity recommendations on a given column (recommendations are enabled by default - on all columns). + """Disables sensitivity recommendations on a given column. :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. Required. @@ -891,10 +1217,10 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_enable_recommendation_request( + request = build_disable_recommendation_request( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, database_name=database_name, @@ -904,7 +1230,7 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - template_url=self.enable_recommendation.metadata["url"], + template_url=self.disable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -925,182 +1251,23 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" - } - - @distributed_trace - def list_current_by_database( - self, - 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.SensitivityLabel"]: - """Gets the sensitivity labels of a given database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param skip_token: Default value is None. - :type skip_token: str - :param count: Default value is None. - :type count: bool - :param filter: An OData filter expression that filters elements in the collection. Default - value is None. - :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 SensitivityLabel or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_current_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_current_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + disable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" } - @overload - def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: _models.SensitivityLabelUpdateList, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: 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: - """ - - @overload - def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: 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: - """ - @distributed_trace - def update( # pylint: disable=inconsistent-return-statements + def enable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, database_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO], + schema_name: str, + table_name: str, + column_name: str, **kwargs: Any ) -> None: - """Update sensitivity labels of a given database using an operations batch. + """Enables sensitivity recommendations on a given column (recommendations are enabled by default + on all columns). :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. Required. @@ -1109,11 +1276,15 @@ def update( # pylint: disable=inconsistent-return-statements :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str - :param parameters: Is either a SensitivityLabelUpdateList type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabelUpdateList or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. + :paramtype sensitivity_label_source: 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 @@ -1127,31 +1298,24 @@ def update( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") - - request = build_update_request( + 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, + sensitivity_label_source=sensitivity_label_source, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], + template_url=self.enable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -1172,18 +1336,16 @@ def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels" + enable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" } @distributed_trace - def list_recommended_by_database( + def list_by_database( self, 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.SensitivityLabel"]: @@ -1196,11 +1358,6 @@ def list_recommended_by_database( :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str - :param skip_token: Default value is None. - :type skip_token: str - :param include_disabled_recommendations: Specifies whether to include disabled recommendations - or not. Default value is None. - :type include_disabled_recommendations: bool :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str @@ -1212,7 +1369,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -1226,16 +1383,14 @@ def list_recommended_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_recommended_by_database_request( + 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, - skip_token=skip_token, - include_disabled_recommendations=include_disabled_recommendations, filter=filter, api_version=api_version, - template_url=self.list_recommended_by_database.metadata["url"], + template_url=self.list_by_database.metadata["url"], headers=_headers, params=_params, ) @@ -1243,7 +1398,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1273,6 +1439,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_recommended_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels" + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/sensitivityLabels" } 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 d4777b59e645..696bb22848af 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -48,7 +49,7 @@ def build_list_by_schema_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +169,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTableListResult] = kwargs.pop("cls", None) error_map = { @@ -198,7 +199,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -271,7 +283,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseTable] = kwargs.pop("cls", None) request = build_get_request( 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 ed641ec63fb0..6d8145e296a9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,30 +37,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -74,7 +69,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -85,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,31 +102,36 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +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, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "tdeName": _SERIALIZER.url("tde_name", tde_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -142,9 +141,11 @@ def build_list_by_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ManagedDatabaseTransparentDataEncryptionOperations: @@ -166,6 +167,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedTransparentDataEncryption"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the managed database for which the transparent data + encryption is defined. Required. + :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 ManagedTransparentDataEncryption or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption" + } + @distributed_trace def get( self, @@ -203,7 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) request = build_get_request( @@ -356,7 +453,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedTransparentDataEncryption] = kwargs.pop("cls", None) @@ -410,88 +507,3 @@ def create_or_update( create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption/{tdeName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedTransparentDataEncryption"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the managed database for which the transparent data - encryption is defined. Required. - :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 ManagedTransparentDataEncryption or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedTransparentDataEncryption] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedTransparentDataEncryptionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/transparentDataEncryption" - } 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 6050f6d9fc59..97857cc91c1c 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 @@ -48,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +92,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +138,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -229,7 +229,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -411,7 +411,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) @@ -510,7 +510,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 cca064d74dff..d01330a30c05 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -37,22 +38,24 @@ _SERIALIZER.client_side_validation = False -def build_initiate_scan_request( +def build_list_by_database_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}/initiateScan", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -61,7 +64,6 @@ def build_initiate_scan_request( "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"), } @@ -70,10 +72,13 @@ def build_initiate_scan_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_export_request( + +def build_get_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -85,13 +90,13 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -112,27 +117,28 @@ def build_export_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( +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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -141,6 +147,7 @@ def build_list_by_database_request( "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"), } @@ -152,10 +159,10 @@ def build_list_by_database_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_initiate_scan_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -164,16 +171,13 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -191,10 +195,7 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class ManagedDatabaseVulnerabilityAssessmentScansOperations: @@ -216,15 +217,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + @distributed_trace + def list_by_database( self, resource_group_name: str, managed_instance_name: str, database_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - scan_id: str, **kwargs: Any - ) -> None: + ) -> Iterable["_models.VulnerabilityAssessmentScanRecord"]: + """Lists the vulnerability assessment scans of a database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :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 VulnerabilityAssessmentScanRecord or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -233,47 +258,71 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_initiate_scan_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, - api_version=api_version, - template_url=self._initiate_scan_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + 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" } @distributed_trace - def begin_initiate_scan( + def get( self, resource_group_name: str, managed_instance_name: str, @@ -281,8 +330,8 @@ def begin_initiate_scan( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> LROPoller[None]: - """Executes a Vulnerability Assessment database scan. + ) -> _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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -297,61 +346,59 @@ def begin_initiate_scan( :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: VulnerabilityAssessmentScanRecord or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._initiate_scan_initial( # type: ignore - 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, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + 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("VulnerabilityAssessmentScanRecord", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" } @distributed_trace @@ -394,7 +441,7 @@ def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) request = build_export_request( @@ -438,39 +485,15 @@ def export( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" } - @distributed_trace - def list_by_database( + def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, managed_instance_name: str, database_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + scan_id: str, **kwargs: Any - ) -> Iterable["_models.VulnerabilityAssessmentScanRecord"]: - """Lists the vulnerability assessment scans of a database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" - Required. - :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 VulnerabilityAssessmentScanRecord or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -479,60 +502,47 @@ def list_by_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - vulnerability_assessment_name=vulnerability_assessment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - def get_next(next_link=None): - request = prepare_request(next_link) + request = build_initiate_scan_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, + api_version=api_version, + template_url=self._initiate_scan_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - 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) + response = pipeline_response.http_response - return pipeline_response + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, None, {}) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" + _initiate_scan_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" } @distributed_trace - def get( + def begin_initiate_scan( self, resource_group_name: str, managed_instance_name: str, @@ -540,8 +550,8 @@ def get( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> _models.VulnerabilityAssessmentScanRecord: - """Gets a vulnerability assessment scan record of a database. + ) -> LROPoller[None]: + """Executes a Vulnerability Assessment database scan. :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. Required. @@ -556,57 +566,59 @@ def get( :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VulnerabilityAssessmentScanRecord or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.VulnerabilityAssessmentScanRecord + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("VulnerabilityAssessmentScanRecord", pipeline_response) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._initiate_scan_initial( # type: ignore + 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, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - return deserialized + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" + begin_initiate_scan.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" } 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 787eab0072c1..8896a627163a 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,32 +37,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -76,7 +69,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -87,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,14 +104,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, database_name: str, @@ -127,9 +117,13 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -150,27 +144,37 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any + +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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -179,10 +183,7 @@ def build_list_by_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ManagedDatabaseVulnerabilityAssessmentsOperations: @@ -204,6 +205,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DatabaseVulnerabilityAssessment"]: + """Lists the vulnerability assessments of a managed database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database for which the vulnerability assessment is + defined. Required. + :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 DatabaseVulnerabilityAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments" + } + @distributed_trace def get( self, @@ -242,7 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -398,7 +495,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -491,7 +588,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -525,88 +622,3 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.DatabaseVulnerabilityAssessment"]: - """Lists the vulnerability assessments of a managed database. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param database_name: The name of the database for which the vulnerability assessment is - defined. Required. - :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 DatabaseVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments" - } 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 740a055b82b6..b55d198894cd 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -168,7 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +204,7 @@ def build_cancel_move_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -235,7 +236,7 @@ def build_complete_move_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -267,7 +268,7 @@ def build_complete_restore_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -299,7 +300,7 @@ def build_start_move_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -331,7 +332,7 @@ def build_list_inaccessible_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -394,7 +395,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -421,7 +422,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -484,7 +496,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( @@ -541,7 +553,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedDatabase]] = kwargs.pop("cls", None) @@ -714,7 +726,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -774,7 +786,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -836,7 +848,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -896,7 +908,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedDatabase]] = kwargs.pop("cls", None) @@ -1066,7 +1078,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedDatabase] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1131,7 +1143,7 @@ def _cancel_move_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1292,7 +1304,7 @@ def begin_cancel_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1355,7 +1367,7 @@ def _complete_move_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1516,7 +1528,7 @@ def begin_complete_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1579,7 +1591,7 @@ def _complete_restore_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1742,7 +1754,7 @@ def begin_complete_restore( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1805,7 +1817,7 @@ def _start_move_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1966,7 +1978,7 @@ def begin_start_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -2029,7 +2041,7 @@ def list_inaccessible_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2056,7 +2068,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 09dedc79c925..e72eecd6a5a9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +154,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -213,7 +214,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdministratorListResult] = kwargs.pop("cls", None) error_map = { @@ -240,7 +241,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -307,7 +319,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) request = build_get_request( @@ -364,7 +376,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAdministrator]] = kwargs.pop("cls", None) @@ -537,7 +549,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAdministrator] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -601,7 +613,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -667,7 +679,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py index 509daca04870..38f2de83b779 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -188,7 +189,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -215,7 +216,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -284,7 +296,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -341,7 +353,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAdvancedThreatProtection]] = kwargs.pop("cls", None) @@ -520,7 +532,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAdvancedThreatProtection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 ca3bfed17c89..c589e7e1c692 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_instance_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -74,7 +70,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, authentication_name: Union[str, _models.AuthenticationName], @@ -84,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,23 +101,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, authentication_name: Union[str, _models.AuthenticationName], subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -140,26 +137,33 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "authenticationName": _SERIALIZER.url("authentication_name", authentication_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -168,10 +172,7 @@ def build_list_by_instance_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ManagedInstanceAzureADOnlyAuthenticationsOperations: @@ -193,6 +194,99 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedInstanceAzureADOnlyAuthentication"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedInstanceAzureADOnlyAuthentication or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications" + } + @distributed_trace def get( self, @@ -227,7 +321,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) request = build_get_request( @@ -284,7 +378,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceAzureADOnlyAuthentication]] = kwargs.pop("cls", None) @@ -469,7 +563,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -533,7 +627,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -600,7 +694,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -640,85 +734,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications/{authenticationName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedInstanceAzureADOnlyAuthentication"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedInstanceAzureADOnlyAuthentication or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceAzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/azureADOnlyAuthentications" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py index 6a05add71fdc..9e1a17e3dfb3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_instance_dtcs_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -182,7 +183,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceDtcListResult] = kwargs.pop("cls", None) error_map = { @@ -209,7 +210,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -272,7 +284,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) request = build_get_request( @@ -329,7 +341,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) @@ -497,7 +509,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceDtc] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 6e0ad8291ec8..1dad0ff4add1 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,25 +39,23 @@ _SERIALIZER.client_side_validation = False -def build_revalidate_request( - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - subscription_id: str, - **kwargs: Any +def build_list_by_instance_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -65,26 +64,34 @@ def build_revalidate_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any + +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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -99,7 +106,7 @@ def build_list_by_instance_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], @@ -109,7 +116,8 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,29 +138,27 @@ def build_get_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_revalidate_request( resource_group_name: str, managed_instance_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -166,12 +172,7 @@ def build_create_or_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class ManagedInstanceEncryptionProtectorsOperations: @@ -193,132 +194,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _revalidate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - managed_instance_name: str, - encryption_protector_name: Union[str, _models.EncryptionProtectorName], - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_revalidate_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, - api_version=api_version, - template_url=self._revalidate_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _revalidate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } - - @distributed_trace - def begin_revalidate( - self, - 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param encryption_protector_name: The name of the encryption protector to be updated. "current" - Required. - :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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._revalidate_initial( # type: ignore - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - encryption_protector_name=encryption_protector_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_revalidate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } - @distributed_trace def list_by_instance( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any @@ -339,7 +214,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceEncryptionProtectorListResult] = kwargs.pop("cls", None) error_map = { @@ -366,7 +241,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -434,7 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) request = build_get_request( @@ -491,7 +377,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceEncryptionProtector]] = kwargs.pop("cls", None) @@ -667,7 +553,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceEncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -712,3 +598,129 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}" } + + def _revalidate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + managed_instance_name: str, + encryption_protector_name: Union[str, _models.EncryptionProtectorName], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_revalidate_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, + api_version=api_version, + template_url=self._revalidate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _revalidate_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" + } + + @distributed_trace + def begin_revalidate( + self, + 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param encryption_protector_name: The name of the encryption protector to be updated. "current" + Required. + :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. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._revalidate_initial( # type: ignore + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + encryption_protector_name=encryption_protector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_revalidate.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate" + } 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 806893cdd721..c4d27381025c 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -49,7 +50,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +115,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -148,7 +149,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -210,7 +211,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceKeyListResult] = kwargs.pop("cls", None) error_map = { @@ -238,7 +239,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -301,7 +313,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) request = build_get_request( @@ -358,7 +370,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceKey]] = kwargs.pop("cls", None) @@ -534,7 +546,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceKey] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -594,7 +606,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -656,7 +668,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 016c050239d3..968d62999be6 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,6 +39,38 @@ _SERIALIZER.client_side_validation = False +def build_list_by_database_request( + resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_get_request( resource_group_name: str, managed_instance_name: str, @@ -49,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,7 +120,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -117,24 +150,30 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, managed_instance_name: str, database_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -146,7 +185,7 @@ def build_list_by_database_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) class ManagedInstanceLongTermRetentionPoliciesOperations: @@ -168,6 +207,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedInstanceLongTermRetentionPolicy"]: + """Gets a database's long term retention policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param database_name: The name of the database. Required. + :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 ManagedInstanceLongTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies" + } + @distributed_trace def get( self, @@ -204,7 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -263,7 +398,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -446,7 +581,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -493,11 +628,76 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } + def _delete_initial( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> Optional[_models.ManagedInstanceLongTermRetentionPolicy]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstanceLongTermRetentionPolicy]] = kwargs.pop("cls", None) + + request = build_delete_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, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" + } + @distributed_trace - def list_by_database( - self, resource_group_name: str, managed_instance_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedInstanceLongTermRetentionPolicy"]: - """Gets a database's long term retention policy. + def begin_delete( + self, + resource_group_name: str, + managed_instance_name: str, + database_name: str, + policy_name: Union[str, _models.ManagedInstanceLongTermRetentionPolicyName], + **kwargs: Any + ) -> LROPoller[_models.ManagedInstanceLongTermRetentionPolicy]: + """Deletes a managed database's long term retention policy. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. Required. @@ -506,74 +706,65 @@ def list_by_database( :type managed_instance_name: str :param database_name: The name of the database. Required. :type database_name: str + :param policy_name: The policy name. Should always be Default. "default" Required. + :type policy_name: str or ~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedInstanceLongTermRetentionPolicy or the - result of cls(response) + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedInstanceLongTermRetentionPolicy or + the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstanceLongTermRetentionPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceLongTermRetentionPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + database_name=database_name, + policy_name=policy_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicyListResult", pipeline_response) - list_of_elem = deserialized.value + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstanceLongTermRetentionPolicy", pipeline_response) if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) + return cls(pipeline_response, deserialized, {}) + return deserialized - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, ) - 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) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies" + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/backupLongTermRetentionPolicies/{policyName}" } 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 1c36e8e5553c..ee879902f046 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +104,7 @@ def build_cancel_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -163,7 +164,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -190,7 +191,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -253,7 +265,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceOperation] = kwargs.pop("cls", None) request = build_get_request( @@ -320,7 +332,7 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( 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 c4ad05844331..539528901246 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,23 @@ _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 +def build_list_by_managed_instance_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -76,7 +70,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, @@ -86,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,23 +103,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -146,26 +141,35 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_managed_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + managed_instance_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -174,10 +178,7 @@ def build_list_by_managed_instance_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ManagedInstancePrivateEndpointConnectionsOperations: @@ -199,6 +200,99 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_managed_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedInstancePrivateEndpointConnection"]: + """Gets all private endpoint connections on a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedInstancePrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_managed_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_managed_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_managed_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections" + } + @distributed_trace def get( self, resource_group_name: str, managed_instance_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -228,7 +322,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -285,7 +379,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstancePrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -458,7 +552,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstancePrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -518,7 +612,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -580,7 +674,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -620,85 +714,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections/{privateEndpointConnectionName}" } - - @distributed_trace - def list_by_managed_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedInstancePrivateEndpointConnection"]: - """Gets all private endpoint connections on a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedInstancePrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstancePrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstancePrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_managed_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_managed_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_managed_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/privateEndpointConnections" - } 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 364b173356ac..01a385df7a79 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +138,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -164,7 +165,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -227,7 +239,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstancePrivateLink] = kwargs.pop("cls", None) request = build_get_request( 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 881d3be5f508..a1a7134052f6 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 @@ -43,7 +43,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -105,7 +105,7 @@ def _create_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -256,7 +256,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 8f2955f8c4a7..8fe1910904b6 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,30 +37,23 @@ _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 +def build_list_by_instance_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "vulnerabilityAssessmentName": _SERIALIZER.url( - "vulnerability_assessment_name", vulnerability_assessment_name, "str" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -74,7 +68,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], @@ -84,8 +78,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,23 +101,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -144,26 +139,35 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any + +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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -172,10 +176,7 @@ def build_list_by_instance_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ManagedInstanceVulnerabilityAssessmentsOperations: @@ -197,6 +198,100 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedInstanceVulnerabilityAssessment"]: + """Gets the managed instance's vulnerability assessment policies. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance for which the vulnerability + assessments is defined. Required. + :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 ManagedInstanceVulnerabilityAssessment or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments" + } + @distributed_trace def get( self, @@ -232,7 +327,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -384,7 +479,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstanceVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -473,7 +568,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -506,86 +601,3 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedInstanceVulnerabilityAssessment"]: - """Gets the managed instance's vulnerability assessment policies. - - :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. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance for which the vulnerability - assessments is defined. Required. - :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 ManagedInstanceVulnerabilityAssessment or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedInstanceVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedInstanceVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/vulnerabilityAssessments" - } 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 8f4c8f06ec20..b15475142758 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_request(subscription_id: str, *, expand: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_list_by_instance_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +109,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +179,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -211,7 +212,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -237,7 +238,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -275,7 +276,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -303,7 +304,7 @@ def build_list_outbound_network_dependencies_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -328,12 +329,46 @@ def build_list_outbound_network_dependencies_by_managed_instance_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_refresh_status_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_start_request( resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -350,15 +385,21 @@ def build_start_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_stop_request( resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -375,7 +416,10 @@ def build_stop_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_managed_instance_request( @@ -395,7 +439,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -467,7 +511,7 @@ def list(self, expand: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -493,7 +537,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -546,7 +601,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -574,7 +629,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -627,7 +693,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstanceListResult] = kwargs.pop("cls", None) error_map = { @@ -654,7 +720,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -717,7 +794,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) request = build_get_request( @@ -773,7 +850,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) @@ -936,7 +1013,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -995,7 +1072,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -1052,7 +1129,7 @@ def begin_delete(self, resource_group_name: str, managed_instance_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1110,7 +1187,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) @@ -1270,7 +1347,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1333,7 +1410,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_failover_request( @@ -1400,7 +1477,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1461,7 +1538,7 @@ def list_outbound_network_dependencies_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) error_map = { @@ -1488,7 +1565,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1522,9 +1610,9 @@ def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints" } - def _start_initial( # pylint: disable=inconsistent-return-statements + def _refresh_status_initial( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> None: + ) -> Optional[_models.RefreshExternalGovernanceStatusOperationResultMI]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1536,8 +1624,134 @@ def _start_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.RefreshExternalGovernanceStatusOperationResultMI]] = kwargs.pop("cls", None) + + request = build_refresh_status_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._refresh_status_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _refresh_status_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus" + } + + @distributed_trace + def begin_refresh_status( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.RefreshExternalGovernanceStatusOperationResultMI]: + """Refresh external governance enablement status. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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. + :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 + RefreshExternalGovernanceStatusOperationResultMI or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.RefreshExternalGovernanceStatusOperationResultMI] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RefreshExternalGovernanceStatusOperationResultMI] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_status_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_refresh_status.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus" + } + + def _start_initial( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Optional[_models.ManagedInstance]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) request = build_start_request( resource_group_name=resource_group_name, @@ -1558,19 +1772,27 @@ def _start_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstance", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _start_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start" } @distributed_trace - def begin_start(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> LROPoller[None]: + def begin_start( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: """Starts the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1586,20 +1808,21 @@ def begin_start(self, resource_group_name: str, managed_instance_name: str, **kw :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either ManagedInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_initial( # type: ignore + raw_result = self._start_initial( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, api_version=api_version, @@ -1610,9 +1833,11 @@ def begin_start(self, resource_group_name: str, managed_instance_name: str, **kw ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstance", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: PollingMethod = cast( @@ -1635,9 +1860,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start" } - def _stop_initial( # pylint: disable=inconsistent-return-statements + def _stop_initial( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> None: + ) -> Optional[_models.ManagedInstance]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1649,8 +1874,8 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ManagedInstance]] = kwargs.pop("cls", None) request = build_stop_request( resource_group_name=resource_group_name, @@ -1671,19 +1896,27 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ManagedInstance", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized _stop_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop" } @distributed_trace - def begin_stop(self, resource_group_name: str, managed_instance_name: str, **kwargs: Any) -> LROPoller[None]: + def begin_stop( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.ManagedInstance]: """Stops the managed instance. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -1699,20 +1932,21 @@ def begin_stop(self, resource_group_name: str, managed_instance_name: str, **kwa :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An instance of LROPoller that returns either ManagedInstance or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ManagedInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedInstance] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._stop_initial( # type: ignore + raw_result = self._stop_initial( resource_group_name=resource_group_name, managed_instance_name=managed_instance_name, api_version=api_version, @@ -1723,9 +1957,11 @@ def begin_stop(self, resource_group_name: str, managed_instance_name: str, **kwa ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ManagedInstance", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + return deserialized if polling is True: polling_method: PollingMethod = cast( @@ -1796,7 +2032,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TopQueriesListResult] = kwargs.pop("cls", None) error_map = { @@ -1830,7 +2066,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py index 1786bc6c6390..3f2072673b1e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_ledger_digest_uploads_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +120,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -160,7 +161,7 @@ def build_disable_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +229,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploadsListResult] = kwargs.pop("cls", None) error_map = { @@ -256,7 +257,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -326,7 +338,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) request = build_get_request( @@ -385,7 +397,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) @@ -571,7 +583,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -637,7 +649,7 @@ def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ManagedLedgerDigestUploads]] = kwargs.pop("cls", None) request = build_disable_request( @@ -715,7 +727,7 @@ def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedLedgerDigestUploads] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 e359253ea2ac..7d47a0b9caba 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +39,23 @@ _SERIALIZER.client_side_validation = False -def build_get_request( +def build_list_by_restorable_dropped_database_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -63,7 +63,6 @@ def build_get_request( "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"), } @@ -78,7 +77,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, @@ -89,8 +88,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,14 +112,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_create_or_update_request( resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, @@ -132,7 +128,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -161,26 +157,28 @@ def build_update_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_restorable_dropped_database_request( +def build_update_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -188,6 +186,7 @@ def build_list_by_restorable_dropped_database_request( "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"), } @@ -197,9 +196,11 @@ def build_list_by_restorable_dropped_database_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) class ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations: @@ -221,6 +222,102 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_restorable_dropped_database( + self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any + ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicy"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :type managed_instance_name: str + :param restorable_dropped_database_id: Required. + :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 ManagedBackupShortTermRetentionPolicy or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_restorable_dropped_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_restorable_dropped_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies" + } + @distributed_trace def get( self, @@ -257,7 +354,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -316,7 +413,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -499,7 +596,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -566,7 +663,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedBackupShortTermRetentionPolicy]] = kwargs.pop("cls", None) @@ -749,7 +846,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedBackupShortTermRetentionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -795,88 +892,3 @@ def get_long_running_output(pipeline_response): begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies/{policyName}" } - - @distributed_trace - def list_by_restorable_dropped_database( - self, resource_group_name: str, managed_instance_name: str, restorable_dropped_database_id: str, **kwargs: Any - ) -> Iterable["_models.ManagedBackupShortTermRetentionPolicy"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :type managed_instance_name: str - :param restorable_dropped_database_id: Required. - :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 ManagedBackupShortTermRetentionPolicy or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedBackupShortTermRetentionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedBackupShortTermRetentionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_restorable_dropped_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_restorable_dropped_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/restorableDroppedDatabases/{restorableDroppedDatabaseId}/backupShortTermRetentionPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py index 73ca27792168..ff105482f993 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_managed_server_dns_aliases_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -168,7 +169,7 @@ def build_acquire_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -236,7 +237,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerDnsAliasListResult] = kwargs.pop("cls", None) error_map = { @@ -263,7 +264,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -326,7 +338,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) request = build_get_request( @@ -383,7 +395,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) @@ -555,7 +567,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -615,7 +627,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -677,7 +689,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -737,7 +749,7 @@ def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerDnsAlias]] = kwargs.pop("cls", None) @@ -906,7 +918,7 @@ def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 a088ac69c690..893447bb1063 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_instance_request( + resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -74,18 +70,17 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,30 +101,34 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_instance_request( - resource_group_name: str, managed_instance_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + managed_instance_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "managedInstanceName": _SERIALIZER.url("managed_instance_name", managed_instance_name, "str"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -139,9 +138,11 @@ def build_list_by_instance_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ManagedServerSecurityAlertPoliciesOperations: @@ -163,12 +164,104 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_instance( + self, resource_group_name: str, managed_instance_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedServerSecurityAlertPolicy"]: + """Get the managed server's threat detection policies. + + :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. Required. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. Required. + :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 ManagedServerSecurityAlertPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_instance_request( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_instance.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_instance.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" + } + @distributed_trace def get( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], **kwargs: Any ) -> _models.ManagedServerSecurityAlertPolicy: """Get a managed server's threat detection policy. @@ -179,7 +272,8 @@ def get( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy @@ -196,7 +290,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -238,7 +332,7 @@ def _create_or_update_initial( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO], **kwargs: Any ) -> Optional[_models.ManagedServerSecurityAlertPolicy]: @@ -253,7 +347,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ManagedServerSecurityAlertPolicy]] = kwargs.pop("cls", None) @@ -310,7 +404,7 @@ def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: _models.ManagedServerSecurityAlertPolicy, *, content_type: str = "application/json", @@ -324,7 +418,8 @@ def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -349,7 +444,7 @@ def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: IO, *, content_type: str = "application/json", @@ -363,7 +458,8 @@ def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -388,7 +484,7 @@ def begin_create_or_update( self, resource_group_name: str, managed_instance_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ManagedServerSecurityAlertPolicy, IO], **kwargs: Any ) -> LROPoller[_models.ManagedServerSecurityAlertPolicy]: @@ -400,7 +496,8 @@ def begin_create_or_update( :param managed_instance_name: The name of the managed instance. Required. :type managed_instance_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The managed server security alert policy. Is either a ManagedServerSecurityAlertPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy or IO @@ -423,7 +520,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -468,84 +565,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_instance( - self, resource_group_name: str, managed_instance_name: str, **kwargs: Any - ) -> Iterable["_models.ManagedServerSecurityAlertPolicy"]: - """Get the managed server's threat detection policies. - - :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. Required. - :type resource_group_name: str - :param managed_instance_name: The name of the managed instance. Required. - :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 ManagedServerSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ManagedServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..8744c0bb128e --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py @@ -0,0 +1,442 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +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_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations", + ) # pylint: disable=line-too-long + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, server_name: str, nsp_config_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reconcile_request( + resource_group_name: str, server_name: str, nsp_config_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class NetworkSecurityPerimeterConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`network_security_perimeter_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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("NetworkSecurityPerimeterConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/networkSecurityPerimeterConfigurations" + } + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets a network security perimeter configuration. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}" + } + + def _reconcile_initial( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> Optional[_models.NetworkSecurityPerimeterConfiguration]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + request = build_reconcile_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reconcile_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reconcile_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } + + @distributed_trace + def begin_reconcile( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> LROPoller[_models.NetworkSecurityPerimeterConfiguration]: + """Reconcile network security perimeter configuration for SQL Resource Provider. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NetworkSecurityPerimeterConfiguration or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reconcile_initial( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_reconcile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } 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 758af7344028..6cf0ea4ca1af 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -39,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +86,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { @@ -109,7 +110,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 bddcecdd6125..8586a69db25e 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 @@ -6,8 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +38,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules", ) # pylint: disable=line-too-long 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"), } @@ -70,14 +69,13 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,19 +96,20 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -128,26 +127,27 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +def build_delete_request( + resource_group_name: str, server_name: str, outbound_rule_fqdn: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}", ) # pylint: disable=line-too-long 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"), } @@ -156,10 +156,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class OutboundFirewallRulesOperations: @@ -181,6 +178,98 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.OutboundFirewallRule"]: + """Gets all outbound firewall rules on a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 OutboundFirewallRule or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/outboundFirewallRules" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any @@ -210,7 +299,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -249,12 +338,7 @@ def get( } def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO], - **kwargs: Any + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any ) -> Optional[_models.OutboundFirewallRule]: error_map = { 401: ClientAuthenticationError, @@ -264,30 +348,18 @@ def _create_or_update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.OutboundFirewallRule]] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "OutboundFirewallRule") - request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, @@ -322,92 +394,9 @@ def _create_or_update_initial( "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" } - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: _models.OutboundFirewallRule, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param outbound_rule_fqdn: Required. - :type outbound_rule_fqdn: str - :param parameters: Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: IO, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param outbound_rule_fqdn: Required. - :type outbound_rule_fqdn: str - :param parameters: Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - outbound_rule_fqdn: str, - parameters: Union[_models.OutboundFirewallRule, IO], - **kwargs: Any + self, resource_group_name: str, server_name: str, outbound_rule_fqdn: str, **kwargs: Any ) -> LROPoller[_models.OutboundFirewallRule]: """Create a outbound firewall rule with a given name. @@ -418,11 +407,6 @@ def begin_create_or_update( :type server_name: str :param outbound_rule_fqdn: Required. :type outbound_rule_fqdn: str - :param parameters: Is either a OutboundFirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.OutboundFirewallRule or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -436,11 +420,10 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.OutboundFirewallRule] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundFirewallRule] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -450,9 +433,7 @@ def begin_create_or_update( resource_group_name=resource_group_name, server_name=server_name, outbound_rule_fqdn=outbound_rule_fqdn, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -499,7 +480,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -561,7 +542,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -601,84 +582,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/outboundFirewallRules/{outboundRuleFqdn}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.OutboundFirewallRule"]: - """Gets all outbound firewall rules on a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 OutboundFirewallRule or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.OutboundFirewallRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) - cls: ClsType[_models.OutboundFirewallRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/outboundFirewallRules" - } 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 fd947bfcb98b..a12dc3287246 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -219,7 +220,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { @@ -246,7 +247,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -309,7 +321,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -366,7 +378,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -535,7 +547,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -595,7 +607,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -657,7 +669,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 b82983f265da..e83305de0f4f 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +137,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { @@ -163,7 +164,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -226,7 +238,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( 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 dc2d0e4048bc..6c371ab597cf 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 @@ -41,7 +41,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -188,7 +188,7 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) 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 2422eb084069..276e823fa824 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +148,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -174,7 +175,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -248,7 +260,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 e0921680ad98..bae1dfbaced6 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,7 +142,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -168,7 +169,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -231,7 +243,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RecoverableManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 a77a4817528b..04951dca9ed5 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -43,7 +44,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -135,7 +136,7 @@ def build_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +169,7 @@ def build_failover_allow_data_loss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +202,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,7 +267,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -294,7 +295,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -359,7 +371,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) request = build_get_request( @@ -412,7 +424,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -477,7 +489,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -533,7 +545,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ReplicationLink]] = kwargs.pop("cls", None) request = build_failover_request( @@ -605,7 +617,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -663,7 +675,7 @@ def _failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ReplicationLink]] = kwargs.pop("cls", None) request = build_failover_allow_data_loss_request( @@ -735,7 +747,7 @@ def begin_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -798,7 +810,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) error_map = { @@ -825,7 +837,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 01cca3bdfdd8..22c323bf3c27 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +151,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -177,7 +178,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -251,7 +263,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 2462c9954a24..9ef52de792a0 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +144,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedManagedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -170,7 +171,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -233,7 +245,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorableDroppedManagedDatabase] = kwargs.pop("cls", None) request = build_get_request( 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 b551b8560185..e8b3da6081cc 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +77,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +117,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +154,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -215,7 +216,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) error_map = { @@ -243,7 +244,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -296,7 +308,7 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.RestorePoint]] = kwargs.pop("cls", None) @@ -469,7 +481,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -546,7 +558,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) request = build_get_request( @@ -616,7 +628,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 6ba7972d9d42..d2dd6f70e9f6 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -55,7 +56,7 @@ def build_list_current_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +94,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -133,7 +134,7 @@ def build_list_recommended_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,24 +168,27 @@ def build_list_recommended_by_database_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_enable_recommendation_request( +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}/enable", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -202,10 +206,13 @@ def build_enable_recommendation_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_disable_recommendation_request( + +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -215,14 +222,18 @@ def build_disable_recommendation_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("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}/disable", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -240,26 +251,28 @@ def build_disable_recommendation_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_delete_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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -281,13 +294,10 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_create_or_update_request( +def build_disable_recommendation_request( resource_group_name: str, server_name: str, database_name: str, @@ -297,18 +307,14 @@ def build_create_or_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -326,15 +332,10 @@ def build_create_or_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_delete_request( +def build_enable_recommendation_request( resource_group_name: str, server_name: str, database_name: str, @@ -346,12 +347,12 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -369,7 +370,47 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sensitivityLabels", + ) # pylint: disable=line-too-long + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class SensitivityLabelsOperations: @@ -426,7 +467,7 @@ def list_current_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -457,7 +498,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -592,7 +644,7 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -674,7 +726,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) error_map = { @@ -705,7 +757,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -740,7 +803,7 @@ def get_next(next_link=None): } @distributed_trace - def enable_recommendation( # pylint: disable=inconsistent-return-statements + def get( self, resource_group_name: str, server_name: str, @@ -748,10 +811,10 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements schema_name: str, table_name: str, column_name: str, + sensitivity_label_source: Union[str, _models.SensitivityLabelSource], **kwargs: Any - ) -> None: - """Enables sensitivity recommendations on a given column (recommendations are enabled by default - on all columns). + ) -> _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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -766,12 +829,12 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. - :paramtype sensitivity_label_source: str + :param sensitivity_label_source: The source of the sensitivity label. Known values are: + "current" and "recommended". Required. + :type sensitivity_label_source: str or ~azure.mgmt.sql.models.SensitivityLabelSource :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 + :return: SensitivityLabel or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -785,21 +848,20 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - request = build_enable_recommendation_request( + 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, sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.enable_recommendation.metadata["url"], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -817,15 +879,19 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = self._deserialize("SensitivityLabel", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" } - @distributed_trace - def disable_recommendation( # pylint: disable=inconsistent-return-statements + @overload + def create_or_update( self, resource_group_name: str, server_name: str, @@ -833,9 +899,12 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements schema_name: str, table_name: str, column_name: str, + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", **kwargs: Any - ) -> None: - """Disables sensitivity recommendations on a given column. + ) -> _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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -850,66 +919,22 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. + :param parameters: The column sensitivity label resource. Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword sensitivity_label_source: The source of the sensitivity label. Default value is + "current". Note that overriding this default value may result in unsupported behavior. :paramtype sensitivity_label_source: 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 + :return: SensitivityLabel or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - sensitivity_label_source=sensitivity_label_source, - api_version=api_version, - template_url=self.disable_recommendation.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" - } - @distributed_trace - def get( + @overload + def create_or_update( self, resource_group_name: str, server_name: str, @@ -917,10 +942,12 @@ def get( schema_name: str, table_name: str, column_name: str, - sensitivity_label_source: Union[str, _models.SensitivityLabelSource], + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.SensitivityLabel: - """Gets the sensitivity label of a given column. + """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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -935,68 +962,21 @@ def get( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param sensitivity_label_source: The source of the sensitivity label. Known values are: - "current" and "recommended". Required. - :type sensitivity_label_source: str or ~azure.mgmt.sql.models.SensitivityLabelSource + :param parameters: The column sensitivity label resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword sensitivity_label_source: The source of the sensitivity label. Default value is + "current". Note that overriding this default value may result in unsupported behavior. + :paramtype sensitivity_label_source: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.sql.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("SensitivityLabel", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } - - @overload + @distributed_trace def create_or_update( self, resource_group_name: str, @@ -1005,9 +985,7 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: _models.SensitivityLabel, - *, - content_type: str = "application/json", + parameters: Union[_models.SensitivityLabel, IO], **kwargs: Any ) -> _models.SensitivityLabel: """Creates or updates the sensitivity label of a given column. @@ -1025,22 +1003,92 @@ def create_or_update( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str + :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or + a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO :keyword sensitivity_label_source: The source of the sensitivity label. Default value is "current". Note that overriding this default value may result in unsupported behavior. :paramtype sensitivity_label_source: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.sql.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def create_or_update( + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _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, + sensitivity_label_source=sensitivity_label_source, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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("SensitivityLabel", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SensitivityLabel", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, @@ -1048,12 +1096,9 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: IO, - *, - content_type: str = "application/json", **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1068,22 +1113,66 @@ def create_or_update( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str :keyword sensitivity_label_source: The source of the sensitivity label. Default value is "current". Note that overriding this default value may result in unsupported behavior. :paramtype sensitivity_label_source: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + 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, + sensitivity_label_source=sensitivity_label_source, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + } @distributed_trace - def create_or_update( + def disable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, @@ -1091,10 +1180,9 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: Union[_models.SensitivityLabel, IO], **kwargs: Any - ) -> _models.SensitivityLabel: - """Creates or updates the sensitivity label of a given column. + ) -> None: + """Disables sensitivity recommendations on a given column. :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. Required. @@ -1109,18 +1197,12 @@ def create_or_update( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or - a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.SensitivityLabel or IO - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. :paramtype sensitivity_label_source: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SensitivityLabel or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SensitivityLabel + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1131,23 +1213,14 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SensitivityLabel") + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_create_or_update_request( + request = build_disable_recommendation_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -1157,10 +1230,7 @@ def create_or_update( subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self.disable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -1174,27 +1244,19 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" + disable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" } @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def enable_recommendation( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, @@ -1204,7 +1266,8 @@ def delete( # pylint: disable=inconsistent-return-statements column_name: str, **kwargs: Any ) -> None: - """Deletes the sensitivity label of a given column. + """Enables sensitivity recommendations on a given column (recommendations are enabled by default + on all columns). :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. Required. @@ -1219,8 +1282,8 @@ def delete( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. + :keyword sensitivity_label_source: Default value is "recommended". Note that overriding this + default value may result in unsupported behavior. :paramtype sensitivity_label_source: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -1238,11 +1301,11 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + request = build_enable_recommendation_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -1252,7 +1315,7 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, sensitivity_label_source=sensitivity_label_source, api_version=api_version, - template_url=self.delete.metadata["url"], + template_url=self.enable_recommendation.metadata["url"], headers=_headers, params=_params, ) @@ -1273,6 +1336,109 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: 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}" + enable_recommendation.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" + } + + @distributed_trace + def list_by_database( + self, + resource_group_name: str, + server_name: str, + database_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SensitivityLabel"]: + """Gets the sensitivity labels of a given database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param filter: An OData filter expression that filters elements in the collection. Default + value is None. + :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 SensitivityLabel or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SensitivityLabel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sensitivityLabels" } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py index 995373b5aa4d..880937c17f40 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_advanced_threat_protection_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +188,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalServerAdvancedThreatProtectionListResult] = kwargs.pop("cls", None) error_map = { @@ -214,7 +215,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -283,7 +295,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) request = build_get_request( @@ -340,7 +352,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAdvancedThreatProtection]] = kwargs.pop("cls", None) @@ -516,7 +528,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAdvancedThreatProtection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 847e4fb2843c..fa5f876bdf91 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 @@ -41,7 +41,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +74,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +106,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -183,7 +183,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.Advisor]] = kwargs.pop("cls", None) request = build_list_by_server_request( @@ -248,7 +248,7 @@ def get(self, resource_group_name: str, server_name: str, advisor_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) request = build_get_request( @@ -388,7 +388,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Advisor] = kwargs.pop("cls", None) 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 c12f85c699d4..8bd26ecbc8e7 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 @@ -39,7 +39,7 @@ def build_get_request(resource_group_name: str, server_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +70,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +142,7 @@ def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) request = build_get_request( @@ -272,7 +272,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAutomaticTuning] = kwargs.pop("cls", None) 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 4ebce3b44e54..c265e7cb259b 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators", ) # pylint: disable=line-too-long 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"), } @@ -74,7 +70,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, administrator_name: Union[str, _models.AdministratorName], @@ -84,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,23 +101,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, administrator_name: Union[str, _models.AdministratorName], subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -140,26 +137,33 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + server_name: str, + administrator_name: Union[str, _models.AdministratorName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}", ) # pylint: disable=line-too-long 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"), } @@ -168,10 +172,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ServerAzureADAdministratorsOperations: @@ -193,6 +194,98 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerAzureADAdministrator"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerAzureADAdministrator or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/administrators" + } + @distributed_trace def get( self, @@ -227,7 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) request = build_get_request( @@ -284,7 +377,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAzureADAdministrator]] = kwargs.pop("cls", None) @@ -460,7 +553,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAzureADAdministrator] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -524,7 +617,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -591,7 +684,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -631,84 +724,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerAzureADAdministrator"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerAzureADAdministrator or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADAdministrator] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AdministratorListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/administrators" - } 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 108cbd208373..a19d97328862 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications", ) # pylint: disable=line-too-long 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"), } @@ -74,7 +70,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, authentication_name: Union[str, _models.AuthenticationName], @@ -84,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,23 +101,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, authentication_name: Union[str, _models.AuthenticationName], subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -140,26 +137,33 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + server_name: str, + authentication_name: Union[str, _models.AuthenticationName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}", ) # pylint: disable=line-too-long 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"), } @@ -168,10 +172,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ServerAzureADOnlyAuthenticationsOperations: @@ -193,6 +194,98 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerAzureADOnlyAuthentication"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerAzureADOnlyAuthentication or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/azureADOnlyAuthentications" + } + @distributed_trace def get( self, @@ -227,7 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) request = build_get_request( @@ -284,7 +377,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerAzureADOnlyAuthentication]] = kwargs.pop("cls", None) @@ -466,7 +559,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerAzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -530,7 +623,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -597,7 +690,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -637,84 +730,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/azureADOnlyAuthentications/{authenticationName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerAzureADOnlyAuthentication"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerAzureADOnlyAuthentication or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerAzureADOnlyAuthentication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.AzureADOnlyAuthListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/azureADOnlyAuthentications" - } 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 df8ad0932f8b..8b2ab4562b9a 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 @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -49,7 +50,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request(resource_group_name: str, server_name: str, subscription_i _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +113,7 @@ def build_create_or_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -180,7 +181,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) error_map = { @@ -207,7 +208,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -270,7 +282,7 @@ def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _mod _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -327,7 +339,7 @@ def _create_or_update_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerBlobAuditingPolicy]] = kwargs.pop("cls", None) @@ -498,7 +510,7 @@ def begin_create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_configuration_options_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_configuration_options_operations.py index 921c2f8eeb96..be32e7db2186 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_configuration_options_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_configuration_options_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_managed_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +188,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConfigurationOptionListResult] = kwargs.pop("cls", None) error_map = { @@ -214,7 +215,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -283,7 +295,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) request = build_get_request( @@ -340,7 +352,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) @@ -514,7 +526,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConfigurationOption] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 397d277ff8ed..9a04c3da30b8 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies", ) # pylint: disable=line-too-long 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"), } @@ -74,7 +70,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, connection_policy_name: Union[str, _models.ConnectionPolicyName], @@ -84,8 +80,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,30 +101,34 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + connection_policy_name: Union[str, _models.ConnectionPolicyName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}", ) # pylint: disable=line-too-long 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"), } @@ -139,9 +138,11 @@ def build_list_by_server_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ServerConnectionPoliciesOperations: @@ -163,6 +164,98 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerConnectionPolicy"]: + """Lists connection policy. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerConnectionPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" + } + @distributed_trace def get( self, @@ -196,7 +289,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -253,7 +346,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerConnectionPolicy]] = kwargs.pop("cls", None) @@ -423,7 +516,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerConnectionPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -468,84 +561,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies/{connectionPolicyName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerConnectionPolicy"]: - """Lists connection policy. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerConnectionPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerConnectionPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) - cls: ClsType[_models.ServerConnectionPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/connectionPolicies" - } 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 0a84dcb3d2ec..f3b3fa094a06 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +118,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +188,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDevOpsAuditSettingsListResult] = kwargs.pop("cls", None) error_map = { @@ -214,7 +215,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -281,7 +293,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) request = build_get_request( @@ -338,7 +350,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerDevOpsAuditingSettings]] = kwargs.pop("cls", None) @@ -508,7 +520,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerDevOpsAuditingSettings] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 176bc60244fe..108ff91992f9 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases", ) # pylint: disable=line-too-long 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"), } @@ -70,13 +70,13 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,15 +99,18 @@ def build_create_or_update_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -125,26 +128,27 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, server_name: str, dns_alias_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}", ) # pylint: disable=line-too-long 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"), } @@ -153,10 +157,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_acquire_request( @@ -165,7 +166,7 @@ def build_acquire_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -213,6 +214,97 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerDnsAlias"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server that the alias is pointing to. Required. + :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 ServerDnsAlias or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/dnsAliases" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, dns_alias_name: str, **kwargs: Any @@ -242,7 +334,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) request = build_get_request( @@ -294,7 +386,7 @@ def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ServerDnsAlias]] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -366,7 +458,7 @@ def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -423,7 +515,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -485,7 +577,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -526,86 +618,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/dnsAliases/{dnsAliasName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerDnsAlias"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server that the alias is pointing to. Required. - :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 ServerDnsAlias or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerDnsAlias] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerDnsAliasListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/dnsAliases" - } - def _acquire_initial( self, resource_group_name: str, @@ -625,7 +637,7 @@ def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerDnsAlias]] = kwargs.pop("cls", None) @@ -794,7 +806,7 @@ def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerDnsAlias] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 abcc8e4d17e5..7aa6e97b4ee3 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -200,7 +201,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerKeyListResult] = kwargs.pop("cls", None) error_map = { @@ -227,7 +228,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -288,7 +300,7 @@ def get(self, resource_group_name: str, server_name: str, key_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) request = build_get_request( @@ -345,7 +357,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerKey]] = kwargs.pop("cls", None) @@ -524,7 +536,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerKey] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -584,7 +596,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -644,7 +656,7 @@ def begin_delete(self, resource_group_name: str, server_name: str, key_name: str _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 83b82b74105f..eb0a184a48eb 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +105,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerOperationListResult] = kwargs.pop("cls", None) error_map = { @@ -131,7 +132,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 b2600a83ba66..ff8657c3f456 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,28 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies", ) # pylint: disable=line-too-long 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"), } @@ -74,18 +70,17 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,30 +101,34 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, + server_name: str, + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}", ) # pylint: disable=line-too-long 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"), } @@ -139,9 +138,11 @@ def build_list_by_server_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) class ServerSecurityAlertPoliciesOperations: @@ -163,12 +164,104 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerSecurityAlertPolicy"]: + """Get the server's threat detection policies. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerSecurityAlertPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/securityAlertPolicies" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], **kwargs: Any ) -> _models.ServerSecurityAlertPolicy: """Get a server's security alert policy. @@ -179,7 +272,8 @@ def get( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the security alert policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy @@ -196,7 +290,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -238,7 +332,7 @@ def _create_or_update_initial( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any ) -> Optional[_models.ServerSecurityAlertPolicy]: @@ -253,7 +347,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerSecurityAlertPolicy]] = kwargs.pop("cls", None) @@ -310,7 +404,7 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: _models.ServerSecurityAlertPolicy, *, content_type: str = "application/json", @@ -324,7 +418,8 @@ def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Required. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. @@ -349,7 +444,7 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: IO, *, content_type: str = "application/json", @@ -363,7 +458,8 @@ def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. @@ -388,7 +484,7 @@ def begin_create_or_update( self, resource_group_name: str, server_name: str, - security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], + security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any ) -> LROPoller[_models.ServerSecurityAlertPolicy]: @@ -400,7 +496,8 @@ def begin_create_or_update( :param server_name: The name of the server. Required. :type server_name: str :param security_alert_policy_name: The name of the threat detection policy. "Default" Required. - :type security_alert_policy_name: str or ~azure.mgmt.sql.models.SecurityAlertPolicyName + :type security_alert_policy_name: str or + ~azure.mgmt.sql.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The server security alert policy. Is either a ServerSecurityAlertPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.sql.models.ServerSecurityAlertPolicy or IO @@ -423,7 +520,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -468,84 +565,3 @@ def get_long_running_output(pipeline_response): begin_create_or_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerSecurityAlertPolicy"]: - """Get the server's threat detection policies. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerSecurityAlertPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerSecurityAlertPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.LogicalServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py index bd76a0ce971b..6432e8138da8 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_certificates_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +108,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -141,7 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -202,7 +203,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustCertificatesListResult] = kwargs.pop("cls", None) error_map = { @@ -229,7 +230,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -292,7 +304,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) request = build_get_request( @@ -349,7 +361,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerTrustCertificate]] = kwargs.pop("cls", None) @@ -522,7 +534,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerTrustCertificate] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -582,7 +594,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -644,7 +656,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 17e596cd9f34..ce95833c07e7 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +39,23 @@ _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 +def build_list_by_location_request( + resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups", ) # pylint: disable=line-too-long 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"), } @@ -70,14 +70,13 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,19 +97,21 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -128,26 +129,29 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_location_request( - resource_group_name: str, location_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, location_name: str, server_trust_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}", ) # pylint: disable=line-too-long 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"), } @@ -156,10 +160,7 @@ def build_list_by_location_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_by_instance_request( @@ -168,7 +169,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -212,6 +213,97 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_location( + self, resource_group_name: str, location_name: str, **kwargs: Any + ) -> Iterable["_models.ServerTrustGroup"]: + """Lists a server trust 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. Required. + :type resource_group_name: str + :param location_name: The name of the region where the resource is located. Required. + :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 ServerTrustGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_location_request( + resource_group_name=resource_group_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups" + } + @distributed_trace def get( self, resource_group_name: str, location_name: str, server_trust_group_name: str, **kwargs: Any @@ -241,7 +333,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -298,7 +390,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ServerTrustGroup]] = kwargs.pop("cls", None) @@ -471,7 +563,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerTrustGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -531,7 +623,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -593,7 +685,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -634,86 +726,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}" } - @distributed_trace - def list_by_location( - self, resource_group_name: str, location_name: str, **kwargs: Any - ) -> Iterable["_models.ServerTrustGroup"]: - """Lists a server trust 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. Required. - :type resource_group_name: str - :param location_name: The name of the region where the resource is located. Required. - :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 ServerTrustGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerTrustGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_location_request( - resource_group_name=resource_group_name, - location_name=location_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_location.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups" - } - @distributed_trace def list_by_instance( self, resource_group_name: str, managed_instance_name: str, **kwargs: Any @@ -733,7 +745,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerTrustGroupListResult] = kwargs.pop("cls", None) error_map = { @@ -760,7 +772,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 c09bda45d5bc..df07ead1f0f2 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,9 +51,9 @@ def build_list_by_server_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/usages", ) # pylint: disable=line-too-long 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -89,7 +90,7 @@ def __init__(self, *args, **kwargs): def list_by_server( self, resource_group_name: str, server_name: str, **kwargs: Any ) -> Iterable["_models.ServerUsage"]: - """Returns server usages. + """Gets server usages. :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. Required. @@ -104,7 +105,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -131,7 +132,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -142,7 +154,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) 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 e4eb673d3eae..1fd17eda928a 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,30 +37,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments", ) # pylint: disable=line-too-long 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"), } @@ -74,7 +68,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], @@ -84,8 +78,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,23 +101,25 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -144,26 +139,35 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + server_name: str, + vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", ) # pylint: disable=line-too-long 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"), } @@ -172,10 +176,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class ServerVulnerabilityAssessmentsOperations: @@ -197,6 +198,98 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.ServerVulnerabilityAssessment"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 ServerVulnerabilityAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/vulnerabilityAssessments" + } + @distributed_trace def get( self, @@ -232,7 +325,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -384,7 +477,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) @@ -473,7 +566,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -506,84 +599,3 @@ def delete( # pylint: disable=inconsistent-return-statements delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServerVulnerabilityAssessment"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServerVulnerabilityAssessment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServerVulnerabilityAssessment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/vulnerabilityAssessments" - } 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 eb64bfb0d3fd..f41344f1c795 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -69,7 +70,7 @@ def build_list_request(subscription_id: str, *, expand: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +98,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +130,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +163,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +196,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -221,7 +222,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -255,7 +256,7 @@ def build_import_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -289,7 +290,7 @@ def build_refresh_status_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -395,7 +396,7 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameAvailabilityResponse] = kwargs.pop("cls", None) @@ -456,7 +457,7 @@ def list(self, expand: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) error_map = { @@ -482,7 +483,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -533,7 +545,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerListResult] = kwargs.pop("cls", None) error_map = { @@ -560,7 +572,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -623,7 +646,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) request = build_get_request( @@ -675,7 +698,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Server]] = kwargs.pop("cls", None) @@ -831,7 +854,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -890,7 +913,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -947,7 +970,7 @@ def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1001,7 +1024,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.Server]] = kwargs.pop("cls", None) @@ -1154,7 +1177,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1217,7 +1240,7 @@ def _import_database_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.ImportExportOperationResult]] = kwargs.pop("cls", None) @@ -1377,7 +1400,7 @@ def begin_import_database( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ImportExportOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1436,7 +1459,7 @@ def _refresh_status_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.RefreshExternalGovernanceStatusOperationResult]] = kwargs.pop("cls", None) request = build_refresh_status_request( @@ -1503,7 +1526,7 @@ def begin_refresh_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RefreshExternalGovernanceStatusOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 deleted file mode 100644 index d0c4bfda18a2..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py +++ /dev/null @@ -1,265 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -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_get_request( - resource_group_name: str, server_name: str, service_objective_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives", - ) # pylint: disable=line-too-long - 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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServiceObjectivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`service_objectives` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get( - self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param service_objective_name: The name of the service objective to retrieve. Required. - :type service_objective_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceObjective or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServiceObjective - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjective] = kwargs.pop("cls", None) - - request = build_get_request( - resource_group_name=resource_group_name, - server_name=server_name, - service_objective_name=service_objective_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("ServiceObjective", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/serviceObjectives/{serviceObjectiveName}" - } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.ServiceObjective"]: - """Returns database service objectives. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 ServiceObjective or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.ServiceObjective] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - cls: ClsType[_models.ServiceObjectiveListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/serviceObjectives" - } 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 6326bb52ad15..adb8b0ab5bde 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 @@ -41,7 +41,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +72,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +144,7 @@ def get(self, resource_group_name: str, managed_instance_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) request = build_get_request( @@ -273,7 +273,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlAgentConfiguration] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py index c1b426db8082..97fd9db2b4f6 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baseline_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -53,7 +54,7 @@ def build_list_by_sql_vulnerability_assessment_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +97,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +180,7 @@ def list_by_sql_vulnerability_assessment( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -208,7 +209,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -287,7 +299,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py index d44bb5e7ed38..bac62a245bb7 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_baselines_operations.py @@ -54,7 +54,7 @@ def build_create_or_update_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -234,7 +234,7 @@ def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py index f1005a02f1ed..5d30f4daec85 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_execute_scan_operations.py @@ -53,7 +53,7 @@ def build_execute_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -117,7 +117,7 @@ def _execute_initial( # pylint: disable=inconsistent-return-statements system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_execute_request( @@ -191,7 +191,7 @@ def begin_execute( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py index 7b31225880ec..5206a4502fa1 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baseline_operations.py @@ -9,6 +9,7 @@ from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -55,7 +56,7 @@ def build_list_by_baseline_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +101,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +147,7 @@ def build_create_or_update_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -236,7 +237,7 @@ def list_by_baseline( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -266,7 +267,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -348,7 +360,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -525,7 +537,7 @@ def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py index 4a95510f8a65..490019131e1f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_rule_baselines_operations.py @@ -53,7 +53,7 @@ def build_delete_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -144,7 +144,7 @@ def delete( # pylint: disable=inconsistent-return-statements system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py index 86c7a4218edf..d16ffc1616e9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scan_result_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -54,7 +55,7 @@ def build_list_by_scan_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +100,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +189,7 @@ def list_by_scan( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -218,7 +219,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -300,7 +312,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanResults] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py index 637882b8344f..84b6fc47df4a 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessment_scans_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -53,7 +54,7 @@ def build_list_by_sql_vulnerability_assessments_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +97,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +180,7 @@ def list_by_sql_vulnerability_assessments( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -208,7 +209,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -285,7 +297,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py index a3e8f6e8735f..1d81167955cd 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_operations.py @@ -43,7 +43,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -119,7 +119,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py index 0594141c0230..1ffae088a146 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_sql_vulnerability_assessments_settings_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +116,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -185,7 +186,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -212,7 +213,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -281,7 +293,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -424,7 +436,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py index 6dbbfa6a7084..00313941de48 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_start_stop_managed_instance_schedules_operations.py @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_by_instance_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +114,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -151,7 +152,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -211,7 +212,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StartStopManagedInstanceScheduleListResult] = kwargs.pop("cls", None) error_map = { @@ -238,7 +239,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -306,7 +318,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) request = build_get_request( @@ -449,7 +461,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.StartStopManagedInstanceSchedule] = kwargs.pop("cls", None) @@ -537,7 +549,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 f696593a813c..66bcfb633564 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -39,7 +40,7 @@ def build_list_by_location_request(location_name: str, subscription_id: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +67,7 @@ def build_get_request(location_name: str, usage_name: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +125,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> Iterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionUsageListResult] = kwargs.pop("cls", None) error_map = { @@ -150,7 +151,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -208,7 +220,7 @@ def get(self, location_name: str, usage_name: str, **kwargs: Any) -> _models.Sub _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionUsage] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py index ddb4bef81350..5b13a538b073 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_synapse_link_workspaces_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -41,7 +42,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +109,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SynapseLinkWorkspaceListResult] = kwargs.pop("cls", None) error_map = { @@ -136,7 +137,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 0bc304619a4f..4dd16a889791 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents", ) # pylint: disable=line-too-long 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"), } @@ -70,14 +70,13 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,19 +97,21 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -128,26 +129,29 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, server_name: str, sync_agent_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}", ) # pylint: disable=line-too-long 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"), } @@ -156,10 +160,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_generate_key_request( @@ -168,7 +169,7 @@ def build_generate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -200,7 +201,7 @@ def build_list_linked_databases_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,6 +246,97 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.SyncAgent"]: + """Lists sync agents in a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server on which the sync agent is hosted. Required. + :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 SyncAgent or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/syncAgents" + } + @distributed_trace def get(self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any) -> _models.SyncAgent: """Gets a sync agent. @@ -272,7 +364,7 @@ def get(self, resource_group_name: str, server_name: str, sync_agent_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) request = build_get_request( @@ -329,7 +421,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncAgent]] = kwargs.pop("cls", None) @@ -499,7 +591,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncAgent] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -559,7 +651,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -621,7 +713,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -662,86 +754,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/syncAgents/{syncAgentName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.SyncAgent"]: - """Lists sync agents in a server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server on which the sync agent is hosted. Required. - :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 SyncAgent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncAgent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncAgentListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/syncAgents" - } - @distributed_trace def generate_key( self, resource_group_name: str, server_name: str, sync_agent_name: str, **kwargs: Any @@ -771,7 +783,7 @@ def generate_key( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgentKeyProperties] = kwargs.pop("cls", None) request = build_generate_key_request( @@ -831,7 +843,7 @@ def list_linked_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncAgentLinkedDatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -859,7 +871,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 afcf55f45bb6..f6725cd88430 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_sync_database_ids_request(location_name: str, subscription_id: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,27 +67,24 @@ def build_list_sync_database_ids_request(location_name: str, subscription_id: st return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_refresh_hub_schema_request( - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - subscription_id: str, - **kwargs: Any +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups", ) # pylint: disable=line-too-long 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"), } @@ -95,10 +93,13 @@ def build_refresh_hub_schema_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_hub_schemas_request( + +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -109,13 +110,13 @@ def build_list_hub_schemas_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -136,29 +137,25 @@ def build_list_hub_schemas_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_logs_request( +def build_create_or_update_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -171,22 +168,17 @@ def build_list_logs_request( _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") - _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") - _params["type"] = _SERIALIZER.query("type", type, "str") - if continuation_token_parameter is not None: - _params["continuationToken"] = _SERIALIZER.query( - "continuation_token_parameter", continuation_token_parameter, "str" - ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_cancel_sync_request( +def build_delete_request( resource_group_name: str, server_name: str, database_name: str, @@ -196,11 +188,11 @@ def build_cancel_sync_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -215,10 +207,10 @@ def build_cancel_sync_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_trigger_sync_request( +def build_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -226,13 +218,17 @@ def build_trigger_sync_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -247,10 +243,15 @@ def build_trigger_sync_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( + +def build_cancel_sync_request( resource_group_name: str, server_name: str, database_name: str, @@ -258,16 +259,13 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -282,13 +280,10 @@ def build_get_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_create_or_update_request( +def build_list_hub_schemas_request( resource_group_name: str, server_name: str, database_name: str, @@ -299,14 +294,13 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -322,28 +316,34 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -356,12 +356,22 @@ def build_delete_request( _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") + _params["type"] = _SERIALIZER.query("type", type, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( +def build_refresh_hub_schema_request( resource_group_name: str, server_name: str, database_name: str, @@ -369,17 +379,13 @@ def build_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -394,32 +400,30 @@ def build_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any +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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync", ) # pylint: disable=line-too-long 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"), } @@ -428,10 +432,7 @@ def build_list_by_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) class SyncGroupsOperations: @@ -468,7 +469,7 @@ def list_sync_database_ids(self, location_name: str, **kwargs: Any) -> Iterable[ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncDatabaseIdListResult] = kwargs.pop("cls", None) error_map = { @@ -494,7 +495,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -528,9 +540,30 @@ def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds" } - def _refresh_hub_schema_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> None: + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.SyncGroup"]: + """Lists sync groups under a hub database. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :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 SyncGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -539,49 +572,73 @@ def _refresh_hub_schema_initial( # pylint: disable=inconsistent-return-statemen } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_refresh_hub_schema_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, - api_version=api_version, - template_url=self._refresh_hub_schema_initial.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("SyncGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, None, {}) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - _refresh_hub_schema_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" + 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}/syncGroups" } @distributed_trace - def begin_refresh_hub_schema( + def get( self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Refreshes a hub database schema. + ) -> _models.SyncGroup: + """Gets a sync 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. Required. @@ -593,89 +650,69 @@ def begin_refresh_hub_schema( :param sync_group_name: The name of the sync group. Required. :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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: SyncGroup or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.SyncGroup :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._refresh_hub_schema_initial( # type: ignore - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + 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, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - begin_refresh_hub_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" - } + response = pipeline_response.http_response - @distributed_trace - def list_hub_schemas( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> Iterable["_models.SyncFullSchemaProperties"]: - """Gets a collection of hub database schemas. + 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) - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :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 SyncFullSchemaProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + deserialized = self._deserialize("SyncGroup", pipeline_response) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + } + def _create_or_update_initial( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, IO], + **kwargs: Any + ) -> Optional[_models.SyncGroup]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -684,72 +721,78 @@ def list_hub_schemas( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - 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, - api_version=api_version, - template_url=self.list_hub_schemas.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.SyncGroup]] = kwargs.pop("cls", None) - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SyncGroup") - def extract_data(pipeline_response): - deserialized = self._deserialize("SyncFullSchemaPropertiesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + request = build_create_or_update_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, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_next(next_link=None): - request = prepare_request(next_link) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response = pipeline_response.http_response - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return pipeline_response + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SyncGroup", pipeline_response) - return ItemPaged(get_next, extract_data) + if response.status_code == 201: + deserialized = self._deserialize("SyncGroup", pipeline_response) - list_hub_schemas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas" + if cls: + 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}" } - @distributed_trace - def list_logs( + @overload + def begin_create_or_update( self, 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, + parameters: _models.SyncGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Iterable["_models.SyncGroupLogProperties"]: - """Gets a collection of sync group logs. + ) -> 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -760,97 +803,76 @@ def list_logs( :type database_name: str :param sync_group_name: The name of the sync group. Required. :type sync_group_name: str - :param start_time: Get logs generated after this time. Required. - :type start_time: str - :param end_time: Get logs generated before this time. Required. - :type end_time: str - :param type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and - "Success". Required. - :type type: str or ~azure.mgmt.sql.models.SyncGroupsType - :param continuation_token_parameter: The continuation token for this operation. Default value - is None. - :type continuation_token_parameter: str + :param parameters: The requested sync group resource state. Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SyncGroupLogProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SyncGroup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_logs.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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) + @overload + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SyncGroup]: + """Creates or updates a sync group. - list_logs.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" - } + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param parameters: The requested sync group resource state. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SyncGroup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def cancel_sync( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> None: - """Cancels a sync group synchronization. + def begin_create_or_update( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + parameters: Union[_models.SyncGroup, IO], + **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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -861,77 +883,77 @@ def cancel_sync( # pylint: disable=inconsistent-return-statements :type database_name: str :param sync_group_name: The name of the sync group. Required. :type sync_group_name: str + :param parameters: The requested sync group resource state. Is either a SyncGroup type or a IO + type. Required. + :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SyncGroup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.cancel_sync.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SyncGroup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - if cls: - return cls(pipeline_response, None, {}) + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - cancel_sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - @distributed_trace - def trigger_sync( # pylint: disable=inconsistent-return-statements + def _delete_initial( # pylint: disable=inconsistent-return-statements self, 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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_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: - """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -943,17 +965,17 @@ def trigger_sync( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_trigger_sync_request( + request = build_delete_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, api_version=api_version, - template_url=self.trigger_sync.metadata["url"], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -967,22 +989,22 @@ def trigger_sync( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202, 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, {}) - trigger_sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync" + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } @distributed_trace - def get( + def begin_delete( self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> _models.SyncGroup: - """Gets a sync group. + ) -> LROPoller[None]: + """Deletes a sync 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. Required. @@ -994,61 +1016,63 @@ def get( :param sync_group_name: The name of the sync group. Required. :type sync_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SyncGroup or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.SyncGroup + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) - - 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, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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("SyncGroup", pipeline_response) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + sync_group_name=sync_group_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - return deserialized + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - get.metadata = { + begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - def _create_or_update_initial( + def _update_initial( self, resource_group_name: str, server_name: str, @@ -1068,7 +1092,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncGroup]] = kwargs.pop("cls", None) @@ -1080,7 +1104,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SyncGroup") - request = build_create_or_update_request( + request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -1090,7 +1114,7 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1104,15 +1128,12 @@ def _create_or_update_initial( response = pipeline_response.http_response - if response.status_code not in [200, 201, 202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SyncGroup", pipeline_response) - - if response.status_code == 201: + deserialized = None + if response.status_code == 200: deserialized = self._deserialize("SyncGroup", pipeline_response) if cls: @@ -1120,12 +1141,12 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = { + _update_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, server_name: str, @@ -1136,7 +1157,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SyncGroup]: - """Creates or updates a sync group. + """Updates a sync 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. Required. @@ -1166,7 +1187,7 @@ def begin_create_or_update( """ @overload - def begin_create_or_update( + def begin_update( self, resource_group_name: str, server_name: str, @@ -1177,7 +1198,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SyncGroup]: - """Creates or updates a sync group. + """Updates a sync 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. Required. @@ -1207,7 +1228,7 @@ def begin_create_or_update( """ @distributed_trace - def begin_create_or_update( + def begin_update( self, resource_group_name: str, server_name: str, @@ -1216,7 +1237,7 @@ def begin_create_or_update( parameters: Union[_models.SyncGroup, IO], **kwargs: Any ) -> LROPoller[_models.SyncGroup]: - """Creates or updates a sync group. + """Updates a sync 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. Required. @@ -1248,14 +1269,14 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -1291,13 +1312,30 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = { + begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - def _delete_initial( # pylint: disable=inconsistent-return-statements + @distributed_trace + def cancel_sync( # pylint: disable=inconsistent-return-statements self, 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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :type sync_group_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: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1309,17 +1347,17 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + 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, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + template_url=self.cancel_sync.metadata["url"], headers=_headers, params=_params, ) @@ -1333,22 +1371,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + cancel_sync.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" } @distributed_trace - def begin_delete( + def list_hub_schemas( self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a sync group. + ) -> Iterable["_models.SyncFullSchemaProperties"]: + """Gets a collection of hub database schemas. :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. Required. @@ -1360,71 +1398,212 @@ def begin_delete( :param sync_group_name: The name of the sync group. Required. :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. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either SyncFullSchemaProperties or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - sync_group_name=sync_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_hub_schemas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, None, {}) + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + 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_hub_schemas.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas" } - def _update_initial( + @distributed_trace + def list_logs( self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, - parameters: Union[_models.SyncGroup, IO], + start_time: str, + end_time: str, + type: Union[str, _models.SyncGroupsType], + continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.SyncGroup]: + ) -> Iterable["_models.SyncGroupLogProperties"]: + """Gets a collection of sync group logs. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :type sync_group_name: str + :param start_time: Get logs generated after this time. Required. + :type start_time: str + :param end_time: Get logs generated before this time. Required. + :type end_time: str + :param type: The types of logs to retrieve. Known values are: "All", "Error", "Warning", and + "Success". Required. + :type type: str or ~azure.mgmt.sql.models.SyncGroupsType + :param continuation_token_parameter: The continuation token for this operation. Default value + is None. + :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 SyncGroupLogProperties or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroupLogProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_logs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_logs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs" + } + + def _refresh_hub_schema_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1433,32 +1612,20 @@ def _update_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SyncGroup]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "SyncGroup") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_update_request( + request = build_refresh_hub_schema_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, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._update_initial.metadata["url"], + template_url=self._refresh_hub_schema_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1476,112 +1643,18 @@ def _update_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SyncGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, None, {}) - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + _refresh_hub_schema_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" } - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: _models.SyncGroup, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :param parameters: The requested sync group resource state. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either SyncGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :type sync_group_name: str - :param parameters: The requested sync group resource state. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either SyncGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_update( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - parameters: Union[_models.SyncGroup, IO], - **kwargs: Any - ) -> LROPoller[_models.SyncGroup]: - """Updates a sync group. + def begin_refresh_hub_schema( + self, 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1592,12 +1665,6 @@ def begin_update( :type database_name: str :param sync_group_name: The name of the sync group. Required. :type sync_group_name: str - :param parameters: The requested sync group resource state. Is either a SyncGroup type or a IO - type. Required. - :type parameters: ~azure.mgmt.sql.models.SyncGroup or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -1606,28 +1673,25 @@ def begin_update( :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 SyncGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.SyncGroup] + :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SyncGroup] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._update_initial( + raw_result = self._refresh_hub_schema_initial( # type: ignore resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, sync_group_name=sync_group_name, - parameters=parameters, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -1635,11 +1699,9 @@ def begin_update( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncGroup", pipeline_response) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + return cls(pipeline_response, None, {}) if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1656,15 +1718,15 @@ def get_long_running_output(pipeline_response): ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" + begin_refresh_hub_schema.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" } @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.SyncGroup"]: - """Lists sync groups under a hub database. + def trigger_sync( # pylint: disable=inconsistent-return-statements + self, 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 obtain this value from the Azure Resource Manager API or the portal. Required. @@ -1673,17 +1735,13 @@ def list_by_database( :type server_name: str :param database_name: The name of the database on which the sync group is hosted. Required. :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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 SyncGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncGroup] + :return: None or the result of cls(response) + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncGroupListResult] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1692,53 +1750,40 @@ def list_by_database( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def extract_data(pipeline_response): - deserialized = self._deserialize("SyncGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) - def get_next(next_link=None): - request = prepare_request(next_link) + 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, + api_version=api_version, + template_url=self.trigger_sync.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) - 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) + response = pipeline_response.http_response - return pipeline_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 ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, None, {}) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups" + trigger_sync.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync" } 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 8a610f490795..4777ebad4b8a 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,32 +39,30 @@ _SERIALIZER.client_side_validation = False -def build_get_request( +def build_list_by_sync_group_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers", ) # pylint: disable=line-too-long 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"), } @@ -78,7 +77,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -90,8 +89,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,14 +112,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -130,9 +126,13 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -152,10 +152,15 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( + +def build_delete_request( resource_group_name: str, server_name: str, database_name: str, @@ -164,13 +169,9 @@ def build_update_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -190,38 +191,36 @@ def build_update_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_by_sync_group_request( +def build_update_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}", ) # pylint: disable=line-too-long 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"), } @@ -231,12 +230,14 @@ def build_list_by_sync_group_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_member_schemas_request( +def build_refresh_member_schema_request( resource_group_name: str, server_name: str, database_name: str, @@ -245,16 +246,13 @@ def build_list_member_schemas_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -270,13 +268,10 @@ def build_list_member_schemas_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_refresh_member_schema_request( +def build_list_member_schemas_request( resource_group_name: str, server_name: str, database_name: str, @@ -285,13 +280,16 @@ def build_refresh_member_schema_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("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}/refreshSchema", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -307,7 +305,10 @@ def build_refresh_member_schema_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class SyncMembersOperations: @@ -329,6 +330,103 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_sync_group( + self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any + ) -> Iterable["_models.SyncMember"]: + """Lists sync members in the given sync 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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group. Required. + :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 SyncMember or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncMember] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_sync_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_sync_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers" + } + @distributed_trace def get( self, @@ -369,7 +467,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) request = build_get_request( @@ -430,7 +528,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncMember]] = kwargs.pop("cls", None) @@ -623,7 +721,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -691,7 +789,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -766,7 +864,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -830,7 +928,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.SyncMember]] = kwargs.pop("cls", None) @@ -1020,7 +1118,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SyncMember] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1068,189 +1166,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}" } - @distributed_trace - def list_by_sync_group( - self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> Iterable["_models.SyncMember"]: - """Lists sync members in the given sync 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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group. Required. - :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 SyncMember or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncMember] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncMemberListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_sync_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_sync_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers" - } - - @distributed_trace - def list_member_schemas( - self, - resource_group_name: str, - server_name: str, - database_name: str, - sync_group_name: str, - sync_member_name: str, - **kwargs: Any - ) -> Iterable["_models.SyncFullSchemaProperties"]: - """Gets a sync member database schema. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database on which the sync group is hosted. Required. - :type database_name: str - :param sync_group_name: The name of the sync group on which the sync member is hosted. - Required. - :type sync_group_name: str - :param sync_member_name: The name of the sync member. Required. - :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 SyncFullSchemaProperties or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_member_schemas.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_member_schemas.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas" - } - def _refresh_member_schema_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, @@ -1271,7 +1186,7 @@ def _refresh_member_schema_initial( # pylint: disable=inconsistent-return-state _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_refresh_member_schema_request( @@ -1346,7 +1261,7 @@ def begin_refresh_member_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1388,3 +1303,111 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_refresh_member_schema.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema" } + + @distributed_trace + def list_member_schemas( + self, + resource_group_name: str, + server_name: str, + database_name: str, + sync_group_name: str, + sync_member_name: str, + **kwargs: Any + ) -> Iterable["_models.SyncFullSchemaProperties"]: + """Gets a sync member database schema. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database on which the sync group is hosted. Required. + :type database_name: str + :param sync_group_name: The name of the sync group on which the sync member is hosted. + Required. + :type sync_group_name: str + :param sync_member_name: The name of the sync member. Required. + :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 SyncFullSchemaProperties or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.SyncFullSchemaProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_member_schemas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_member_schemas.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas" + } 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 8928fbd31a55..9166f802c57b 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 @@ -43,7 +43,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -101,7 +101,7 @@ def _create_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -248,7 +248,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 770545bf621c..e1972d2ec3f1 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -39,7 +40,7 @@ def build_list_by_location_request(location_name: str, subscription_id: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +67,7 @@ def build_get_request(location_name: str, time_zone_id: str, subscription_id: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +125,7 @@ def list_by_location(self, location_name: str, **kwargs: Any) -> Iterable["_mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeZoneListResult] = kwargs.pop("cls", None) error_map = { @@ -150,7 +151,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -208,7 +220,7 @@ def get(self, location_name: str, time_zone_id: str, **kwargs: Any) -> _models.T _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.TimeZone] = kwargs.pop("cls", None) request = build_get_request( 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 d7db2b42057a..952a372afa5e 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +120,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -192,7 +193,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryptionListResult] = kwargs.pop("cls", None) error_map = { @@ -220,7 +221,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -291,7 +303,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) request = build_get_request( @@ -350,7 +362,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.LogicalDatabaseTransparentDataEncryption]] = kwargs.pop("cls", None) @@ -539,7 +551,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LogicalDatabaseTransparentDataEncryption] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 8be3350dcf72..9eb3e6ef4baf 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 @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -46,7 +47,7 @@ def build_list_by_instance_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +115,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UsageListResult] = kwargs.pop("cls", None) error_map = { @@ -142,7 +143,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" 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 5a598c4fdb23..78c02e0a61f2 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -42,7 +43,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +67,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +97,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +127,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -152,7 +153,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +187,7 @@ def build_update_dns_servers_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,7 +243,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.VirtualCluster"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) error_map = { @@ -267,7 +268,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -314,7 +326,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualClusterListResult] = kwargs.pop("cls", None) error_map = { @@ -340,7 +352,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -399,7 +422,7 @@ def get(self, resource_group_name: str, virtual_cluster_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) request = build_get_request( @@ -450,7 +473,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -507,7 +530,7 @@ def begin_delete(self, resource_group_name: str, virtual_cluster_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -565,7 +588,7 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.VirtualCluster]] = kwargs.pop("cls", None) @@ -725,7 +748,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualCluster] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -784,7 +807,7 @@ def _update_dns_servers_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.UpdateVirtualClusterDnsServersOperation]] = kwargs.pop("cls", None) request = build_update_dns_servers_request( @@ -852,7 +875,7 @@ def begin_update_dns_servers( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.UpdateVirtualClusterDnsServersOperation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 733b41bf657f..fb3540b89282 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,24 +39,23 @@ _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 +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules", ) # pylint: disable=line-too-long 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"), } @@ -70,14 +70,13 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,19 +97,21 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -128,26 +129,29 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_server_request( - resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, server_name: str, virtual_network_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}", ) # pylint: disable=line-too-long 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"), } @@ -156,10 +160,7 @@ def build_list_by_server_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class VirtualNetworkRulesOperations: @@ -181,6 +182,97 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualNetworkRule"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :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 VirtualNetworkRule or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + 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, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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}/virtualNetworkRules" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, virtual_network_rule_name: str, **kwargs: Any @@ -210,7 +302,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) request = build_get_request( @@ -267,7 +359,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.VirtualNetworkRule]] = kwargs.pop("cls", None) @@ -440,7 +532,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualNetworkRule] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -500,7 +592,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -562,7 +654,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -602,83 +694,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualNetworkRule"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :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 VirtualNetworkRule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.VirtualNetworkRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.VirtualNetworkRuleListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - 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, - api_version=api_version, - template_url=self.list_by_server.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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}/virtualNetworkRules" - } 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 bbeef80d5b70..186486107d41 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,32 +39,30 @@ _SERIALIZER.client_side_validation = False -def build_get_request( +def build_list_by_workload_group_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: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("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}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers", ) # pylint: disable=line-too-long 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"), } @@ -78,7 +77,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -90,8 +89,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,14 +112,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -130,9 +126,13 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -152,33 +152,37 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_workload_group_request( + +def build_delete_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: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", ) # pylint: disable=line-too-long 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"), } @@ -187,10 +191,7 @@ def build_list_by_workload_group_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class WorkloadClassifiersOperations: @@ -212,6 +213,104 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_workload_group( + self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadClassifier"]: + """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 + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :type database_name: str + :param workload_group_name: The name of the workload group from which to receive the + classifiers from. Required. + :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 WorkloadClassifier or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + 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, + api_version=api_version, + template_url=self.list_by_workload_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **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_workload_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers" + } + @distributed_trace def get( self, @@ -252,7 +351,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) request = build_get_request( @@ -313,7 +412,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.WorkloadClassifier]] = kwargs.pop("cls", None) @@ -512,7 +611,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -580,7 +679,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -655,7 +754,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -697,90 +796,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" } - - @distributed_trace - def list_by_workload_group( - self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any - ) -> Iterable["_models.WorkloadClassifier"]: - """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 - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :type database_name: str - :param workload_group_name: The name of the workload group from which to receive the - classifiers from. Required. - :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 WorkloadClassifier or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadClassifier] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - 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, - api_version=api_version, - template_url=self.list_by_workload_group.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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_workload_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers" - } 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 2bab42286f20..dfea3aedb895 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 @@ -8,6 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -38,30 +39,24 @@ _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 +def build_list_by_database_request( + resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups", ) # pylint: disable=line-too-long 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"), } @@ -76,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, server_name: str, database_name: str, @@ -87,8 +82,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,14 +104,12 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_create_or_update_request( resource_group_name: str, server_name: str, database_name: str, @@ -125,9 +117,13 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", @@ -146,27 +142,35 @@ def build_delete_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_database_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, **kwargs: Any + +def build_delete_request( + resource_group_name: str, + server_name: str, + database_name: str, + workload_group_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}", ) # pylint: disable=line-too-long 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"), } @@ -175,10 +179,7 @@ def build_list_by_database_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) class WorkloadGroupsOperations: @@ -200,6 +201,100 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace + def list_by_database( + self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadGroup"]: + """Gets the list of workload groups. + + :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. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param database_name: The name of the database. Required. + :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 WorkloadGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_database_request( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_database.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, database_name: str, workload_group_name: str, **kwargs: Any @@ -231,7 +326,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -290,7 +385,7 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Optional[_models.WorkloadGroup]] = kwargs.pop("cls", None) @@ -473,7 +568,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -534,7 +629,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -599,7 +694,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -640,86 +735,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}" } - - @distributed_trace - def list_by_database( - self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any - ) -> Iterable["_models.WorkloadGroup"]: - """Gets the list of workload groups. - - :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. Required. - :type resource_group_name: str - :param server_name: The name of the server. Required. - :type server_name: str - :param database_name: The name of the database. Required. - :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 WorkloadGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.WorkloadGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-11-01-preview")) - cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - server_name=server_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_database.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", 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) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups" - } diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_create_or_update.py index 75b0a5eb2b1e..a8f9d6a5773b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_create_or_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AdministratorCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py index a621d70f32d2..380b2cb8b2e2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AdministratorDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py index e4fd018baeee..0fc07a370077 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AdministratorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py index 8dd3b268055b..7fd31fd506bb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AdministratorList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_create_or_update.py index 514cd752b553..93c524be4f1d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_create_or_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_delete.py index 4635510ce3ad..26330d5a7933 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AzureADOnlyAuthDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_get.py index 5ae544803c4e..e275e32c4d15 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AzureADOnlyAuthGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_list.py index a620d1ae9888..5912ce03f7f7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/azure_ad_only_auth_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/AzureADOnlyAuthList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_database_operation.py b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_database_operation.py index cddf721799ac..990e44ca577e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_database_operation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_database_operation.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/CancelDatabaseOperation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CancelDatabaseOperation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_elastic_pool_operation.py b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_elastic_pool_operation.py index 8b9a14cab7d6..b3af480ec0ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_elastic_pool_operation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_elastic_pool_operation.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelElasticPoolOperation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CancelElasticPoolOperation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_job_execution.py b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_job_execution.py index 2e16d38fd68f..f11e8b7fc681 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_job_execution.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_job_execution.py @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelJobExecution.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CancelJobExecution.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_managed_instance_operation.py b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_managed_instance_operation.py index 743edb55812e..0540ae223c42 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/cancel_managed_instance_operation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/cancel_managed_instance_operation.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelManagedInstanceOperation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CancelManagedInstanceOperation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py b/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py new file mode 100644 index 000000000000..bbb3207167e2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/change_long_term_retention_backup_access_tier.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python change_long_term_retention_backup_access_tier.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.long_term_retention_backups.begin_change_access_tier( + location_name="japaneast", + long_term_retention_server_name="serverName", + long_term_retention_database_name="databaseName", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", + parameters={"backupStorageAccessTier": "Hot", "operationMode": "Copy"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ChangeLongTermRetentionBackupAccessTier.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py index ea31c2f591c4..be9ac461b87e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_already_exists.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CheckNameAvailabilityServerAlreadyExists.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAlreadyExists.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_available.py b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_available.py index 557f2cb60d47..d17de0c65aa1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_available.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_available.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CheckNameAvailabilityServerAvailable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAvailable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_invalid.py b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_invalid.py index ec0342bb9b55..e7a8d824e76d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_invalid.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/check_name_availability_server_invalid.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CheckNameAvailabilityServerInvalid.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerInvalid.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_create_max.py index 7f4740c0b4f4..8375fe98ad49 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_create_max.py @@ -38,6 +38,7 @@ def main(): column_name="myColumn", parameters={ "properties": { + "clientClassificationSource": "Native", "informationType": "PhoneNumber", "informationTypeId": "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", "labelId": "bf91e08c-f4f0-478a-b016-25164b2a65ff", @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnSensitivityLabelCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ColumnSensitivityLabelCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_delete.py index e0a8b816c29e..13563086379d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_delete.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnSensitivityLabelDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ColumnSensitivityLabelDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_get.py index b03bde7daa70..fd0da0ea2d35 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/column_sensitivity_label_get.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnSensitivityLabelGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ColumnSensitivityLabelGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_max.py index 621ef01993d5..10d67e5fa519 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_max.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ColumnsListByDatabaseMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_min.py index 4c4ef960ce8a..e99caf84e15a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/columns_list_by_database_min.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ColumnsListByDatabaseMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py index 31ab292a4a54..6c4778db84c9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py index 1600b7a452f4..ecb6deb55a82 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseCopyMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseCopyMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py index 72e335a34fc3..2e57867d75b3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py index 0a9a2c9fe397..0d8c36c8142c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseDefaultMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py index 520c099a8bf4..74ba1ed18dcc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py index e4f26a19c926..927654a9c943 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseLedger.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseLedger.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py index dc7c33d152d1..c62f6443b71a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py index 61428c8029a7..4e391998da98 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py index db28d045c929..486383660c51 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseNamedReplica.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseNamedReplica.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py index edadf1ac8933..a3f39dc43d05 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabasePITRMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabasePITRMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py index c7c30d185f7f..b7ccc4d6b4ac 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseSecondaryMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseSecondaryMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py index 3cb64d9b8b23..e5acf99ca504 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseStandbyMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseStandbyMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py index d1a7939f8668..749cb5db5937 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py index 4f84673bf446..31e1bd6245ef 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDatabaseWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py index 565071026df2..2666a019bbc9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py index 26cacec27ac8..5d85cf4d06df 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py index 8bb52bcaf34e..239f904b85ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py index afd1c989d29c..aea07d3b6fcf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateElasticPoolWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateElasticPoolWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_job_execution.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_job_execution.py index 140cae942888..3e686b63e144 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_job_execution.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_job_execution.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateJobExecution.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateJobExecution.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_database_ledger.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_database_ledger.py index 940c66c3aa79..66fb604f7ae0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_database_ledger.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_managed_database_ledger.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateManagedDatabaseLedger.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateManagedDatabaseLedger.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_database_extensions.py index d45e2fd3a92d..578bf17e247a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_database_extensions.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_database_extensions.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/CreateOrUpdateDatabaseExtensions.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateDatabaseExtensions.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_max.py index 588367a4b077..6d23a29930c3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_max.py @@ -36,6 +36,7 @@ def main(): "location": "japaneast", "properties": { "licenseType": "LicenseIncluded", + "maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1", "subnetId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet1", "vCores": 8, }, @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateInstancePoolMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_min.py index 952d96b98136..134acc633763 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_instance_pool_min.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateInstancePoolMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent.py index f066e0b16e8b..16496ab84782 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py new file mode 100644 index 000000000000..db17f807687d --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_agent_with_identity.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_or_update_job_agent_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.job_agents.begin_create_or_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + }, + "location": "southeastasia", + "properties": { + "databaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/db1" + }, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobAgentWithIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_credential.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_credential.py index 4138903a7b1f..4f1960221f32 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_credential.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_credential.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobCredential.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobCredential.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_execution.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_execution.py index e9838af25e90..845c2802ad59 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_execution.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_execution.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobExecution.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobExecution.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_max.py index aecc978f14d7..ecb5ad4b358f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_max.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py new file mode 100644 index 000000000000..9b684cd9fa92 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_private_endpoint.py @@ -0,0 +1,48 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python create_or_update_job_private_endpoint.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.job_private_endpoints.begin_create_or_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + private_endpoint_name="endpoint1", + parameters={ + "properties": { + "targetServerAzureResourceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/targetserver1" + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobPrivateEndpoint.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py index 7c9648df36f1..f1a7ffe792ed 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_max.py @@ -64,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobStepMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_min.py index de2a5fce51c5..13c7d3b0cdd3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_step_min.py @@ -38,7 +38,6 @@ def main(): parameters={ "properties": { "action": {"value": "select 1"}, - "credential": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0", "targetGroup": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0", } }, @@ -46,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobStepMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_max.py index e8448ddf295a..887956b35aa1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_max.py @@ -70,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobTargetGroupMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_min.py index ec6451e2d78a..05994ea92b40 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_job_target_group_min.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateJobTargetGroupMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_maintenance_windows.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_maintenance_windows.py index 4dfafe61ffab..68eb15a4fc17 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_maintenance_windows.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_maintenance_windows.py @@ -40,6 +40,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateMaintenanceWindows.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateMaintenanceWindows.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_max.py index 8cd1a27f308a..3d5363838632 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_max.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_min.py index 821c37e5302d..f2c78892535e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_classifier_min.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_max.py index a14154818b23..d44341fa0abd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_max.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_min.py index 60c8eb07ec8d..311a072fd39d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_or_update_workload_group_min.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py index 60d5dcb22602..dc68d8d794db 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py index ab44b6f097a4..a1d647b32b70 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py index ae81b6b823d8..df0e3e770f39 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py @@ -33,11 +33,12 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", parameters={"properties": {"dataMaskingState": "Enabled", "exemptPrincipals": "testuser;"}}, ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingPolicyCreateOrUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_min.py index e5dc4141c90f..051b7ce0319e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_min.py @@ -33,11 +33,12 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", parameters={"properties": {"dataMaskingState": "Enabled"}}, ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingPolicyCreateOrUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_get.py index 9c89c501ac62..e1a060ae6768 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_get.py @@ -33,10 +33,11 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_max.py index aeb43781c2ec..ba8bc234f7da 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_max.py @@ -33,6 +33,7 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", data_masking_rule_name="rule1", parameters={ "properties": { @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleCreateOrUpdateDefaultMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingRuleCreateOrUpdateDefaultMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_min.py index 0825719a912b..30a9de1dde7b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_default_min.py @@ -33,6 +33,7 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", data_masking_rule_name="rule1", parameters={ "properties": { @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleCreateOrUpdateDefaultMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingRuleCreateOrUpdateDefaultMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_number.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_number.py index 93e19a5bbce3..f10b1f2c782d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_number.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_number.py @@ -33,6 +33,7 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", data_masking_rule_name="rule1", parameters={ "properties": { @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleCreateOrUpdateNumber.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingRuleCreateOrUpdateNumber.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_text.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_text.py index 3b5529d59021..99c947c584b1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_text.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_create_or_update_text.py @@ -33,6 +33,7 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", data_masking_rule_name="rule1", parameters={ "properties": { @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleCreateOrUpdateText.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingRuleCreateOrUpdateText.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list_by_database.py similarity index 89% rename from sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list_by_database.py index 6bb448a9bafc..4a6b6aec6954 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_rule_list_by_database.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python data_masking_rule_list.py + python data_masking_rule_list_by_database.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -33,11 +33,12 @@ def main(): resource_group_name="sqlcrudtest-6852", server_name="sqlcrudtest-2080", database_name="sqlcrudtest-331", + data_masking_policy_name="Default", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingRuleList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataMaskingRuleListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_get.py index 819971d9d959..396adfeb9c5c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataWarehouseRestorePointsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_list_by_database.py index 0f30207f8232..505ea789b280 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/data_warehouse_restore_points_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DataWarehouseRestorePointsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_max.py index 57325df63a9a..f45b461a2952 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_max.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_min.py index 3faf0ec380cd..7649607772d8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_create_min.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_get.py index 3a7550b1e6a6..e6cf1390aa25 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_list_by_database.py index a3c542c56f7f..bdb0a1d7a797 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advanced_threat_protection_settings_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_get.py index 0043467b95a7..3874807270c3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvisorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_list.py index a142bd2b282a..cd793aee4d2b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_list.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvisorList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_update.py index fee9f7de6ff1..e4413281a34b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_advisor_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAdvisorUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_auditing_settings_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_auditing_settings_list.py index 831e4c171979..5112799fc7ec 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_auditing_settings_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_auditing_settings_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAuditingSettingsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAuditingSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_get.py index 5eb116e397ad..ee4581b5156c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAutomaticTuningGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAutomaticTuningGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_max.py index f949a0b4ab4e..2e9ce67f6d0f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_max.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAutomaticTuningUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAutomaticTuningUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_min.py index 70fa97ab92b9..913ae3bb403c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_automatic_tuning_update_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAutomaticTuningUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAutomaticTuningUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_azure_monitor_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_azure_monitor_auditing_create_min.py index 3250f6f8186d..dba0309ddeb0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_azure_monitor_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_azure_monitor_auditing_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAzureMonitorAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseAzureMonitorAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_max.py index cd43003f2028..61f81e567348 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_max.py @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseBlobAuditingCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_min.py index baff274b6c05..f91b8f0c7ae9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_create_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseBlobAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_get.py index 9c1a9dfb21b4..6382e80f1a2d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_blob_auditing_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseBlobAuditingGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_column_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_column_get.py index adfc7272f2ca..59f16335bc34 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_column_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_column_get.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseColumnGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_column_list_by_table.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_column_list_by_table.py index b56a1b4b68b7..bfbee7955ad9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_column_list_by_table.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_column_list_by_table.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnListByTable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseColumnListByTable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revalidate.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revalidate.py index 951569248ddd..b201753635a2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revalidate.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revalidate.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevalidate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseEncryptionProtectorRevalidate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revert.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revert.py index 04a2e9842e78..544bb03a6fa7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revert.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_encryption_protector_revert.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevert.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseEncryptionProtectorRevert.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_extended_auditing_settings_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_extended_auditing_settings_list.py index ecd2d66ec9d9..9ff2b31cafa7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_extended_auditing_settings_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_extended_auditing_settings_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseExtendedAuditingSettingsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseExtendedAuditingSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_get.py index c9ec704742c4..9774f3153b65 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRecommendedActionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list.py index 3e63c55c2f9c..2dd65cb029d5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRecommendedActionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list_expand.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list_expand.py index 29746fb88ad7..87fee373b973 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list_expand.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_list_expand.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionListExpand.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRecommendedActionListExpand.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_update.py index 2ae2710f5860..bb22cb81837f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_recommended_action_update.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRecommendedActionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_delete.py index b9f62a2b7a15..6627ebb1e4f3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_delete.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRestorePointsDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_get.py index b46f7902b898..b1b16fcd6612 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRestorePointsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_list_by_database.py index dfed545b9981..105e416ad825 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRestorePointsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_post.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_post.py index 73dc7bcf5aa5..e1aaec81fc4a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_post.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_restore_points_post.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsPost.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseRestorePointsPost.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_get.py index ff3900ead894..925c4dabeb8d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSchemaGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_list_by_database.py index b3897e68aea9..aaa140f20caa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_schema_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSchemaListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_max.py index a5177beeb6e1..d60c69a2c9e0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_max.py @@ -33,7 +33,7 @@ def main(): resource_group_name="securityalert-4799", server_name="securityalert-6440", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", parameters={ "properties": { "disabledAlerts": ["Sql_Injection", "Usage_Anomaly"], @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSecurityAlertCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_min.py index c3e30b8314f9..9ed95a71117b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_create_min.py @@ -33,12 +33,12 @@ def main(): resource_group_name="securityalert-4799", server_name="securityalert-6440", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", parameters={"properties": {"state": "Enabled"}}, ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSecurityAlertCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_get.py index 379d5e7906a6..7797c767f842 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_get.py @@ -33,11 +33,11 @@ def main(): resource_group_name="securityalert-6852", server_name="securityalert-2080", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSecurityAlertGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_list_by_database.py index 6699bab786df..6fa3e65f26fa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_security_alert_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSecurityAlertListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add.py index 800e98a40c86..66552c5eb941 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAdd.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAdd.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add_latest.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add_latest.py index b6ff574a09f7..3cd456aff411 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add_latest.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_add_latest.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAddLatest.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAddLatest.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_get.py index 1031924a1e1f..8666c7fa467b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py index 4292826eea36..03d53389bd4e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_get.py index 803bdd76c1e2..9b427fbc7582 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_by_database.py index 80a51b6d5c4c..552c61a3b1f0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_scans_results.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_scans_results.py index 49c31971522a..75603695a700 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_scans_results.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_list_scans_results.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListScansResults.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListScansResults.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_create.py index 20005cd98146..d9ecd7dcd78b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_create.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_delete.py index dfc15137921a..340db791d6f1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_delete.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_get.py index 891a5a484824..c6b0fe7dd4ec 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_get.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_list_by_baseline.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_list_by_baseline.py index f4438389a701..e796303ab892 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_list_by_baseline.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_rule_baseline_list_by_baseline.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineListByBaseline.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineListByBaseline.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan.py index bbed9f52544c..6c9e7d53c4e4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScan.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScan.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan_records_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan_records_list_by_database.py index daba614b2056..d442389b9c64 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan_records_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scan_records_list_by_database.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScanRecordsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_execute.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_execute.py index c218fda950ba..1ca644146e28 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_execute.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_execute.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_results.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_results.py index 2a31c0d713d5..8d16814f9b13 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_results.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_sql_vulnerability_assessment_scans_results.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansResults.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansResults.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_table_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_table_get.py index b7870d72226b..c86c3a42e418 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_table_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_table_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseTableGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_table_list_by_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_table_list_by_schema.py index 00d3bd285bfe..6b41b0485c07 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_table_list_by_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_table_list_by_schema.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableListBySchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseTableListBySchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_container_sas_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_container_sas_key_min.py index 7f3739623d48..cb46c998434e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_container_sas_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_container_sas_key_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateContainerSasKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentCreateContainerSasKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_max.py index ecd652baddd7..5e9795f28581 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_max.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_storage_access_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_storage_access_key_min.py index 64923bb89229..c9a82c6c2a8a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_storage_access_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_create_storage_access_key_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateStorageAccessKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentCreateStorageAccessKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_delete.py index c3d20b02dc4a..00dd01b49748 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_delete.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_get.py index 68c3830d57a7..558c56d60ed6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_list_by_database.py index 20a4ce517bac..a7b7df64f658 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_create.py index a9b0b47285d1..cfd927b3acab 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_create.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_delete.py index 2490a6445142..8ba29c0fce36 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_delete.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_get.py index 2e379f723e35..1db1aa1346d6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_rule_baseline_get.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_export.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_export.py index 47a7a0f97557..a2da308d22e8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_export.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_export.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanExport.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentScanExport.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_get.py index ed166af197e8..471daaaee1c5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_list_by_database.py index 2538bf56fcfd..51af61ab5a9d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scan_records_list_by_database.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scans_execute.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scans_execute.py index 2117b7b47a8e..67b2a0bed1f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scans_execute.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/database_vulnerability_assessment_scans_execute.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py index 6d6909387575..75438668fb68 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/DeleteDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py index f0937df86af9..9c60b2c40e72 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteInstancePool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteInstancePool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py index 03e616bc0d70..fe411b772fd4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJob.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_agent.py index 9c054dcfd4ac..0c67dd7dd6d1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_agent.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_credential.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_credential.py index b323eeea3619..95705bf46ac2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_credential.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_credential.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobCredential.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobCredential.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py new file mode 100644 index 000000000000..399caabe79a0 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_private_endpoint.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python delete_job_private_endpoint.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + client.job_private_endpoints.begin_delete( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + private_endpoint_name="endpoint1", + ).result() + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobPrivateEndpoint.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py index 9f86d1634661..c6611a2b2361 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_step.py @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobStep.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobStep.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_target_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_target_group.py index 3f15996428e1..c06e40995456 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_target_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job_target_group.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobTargetGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteJobTargetGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_classifier.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_classifier.py index cad396212418..1b69686c8e98 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_classifier.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_classifier.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadClassifier.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteWorkloadClassifier.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_group.py index e035505b4552..2272416789e9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_workload_group.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteWorkloadGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_get.py index 04eb62fe0e40..b1d50d94e5f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeletedServerGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list.py index d4e33138e134..d819b7f3560e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeletedServerList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list_by_subscription.py b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list_by_subscription.py index 86548b545cf6..b9fc6a533fb6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list_by_subscription.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_list_by_subscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerListBySubscription.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeletedServerListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_recover.py b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_recover.py index cab27856101c..b74d4c2bf595 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_recover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/deleted_server_recover.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerRecover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeletedServerRecover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py new file mode 100644 index 000000000000..78d64170ff57 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_max.py @@ -0,0 +1,53 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_create_max.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_create_or_update( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={ + "properties": { + "databases": [{"databaseName": "testdb"}], + "failoverMode": "None", + "instanceAvailabilityGroupName": "testcl", + "instanceLinkRole": "Primary", + "partnerAvailabilityGroupName": "BoxLocalAg1", + "partnerEndpoint": "TCP://SERVER:7022", + "seedingMode": "Automatic", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsCreateMax.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py similarity index 80% rename from sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py rename to sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py index 8d1eca0c6e45..54cc074c9766 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_create_min.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python distributed_availability_groups_create.py + python distributed_availability_groups_create_min.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -35,16 +35,16 @@ def main(): distributed_availability_group_name="dag", parameters={ "properties": { - "primaryAvailabilityGroupName": "BoxLocalAg1", - "secondaryAvailabilityGroupName": "testcl", - "sourceEndpoint": "TCP://SERVER:7022", - "targetDatabase": "testdb", + "databases": [{"databaseName": "testdb"}], + "instanceAvailabilityGroupName": "testcl", + "partnerAvailabilityGroupName": "BoxLocalAg1", + "partnerEndpoint": "TCP://SERVER:7022", } }, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py index de7fdbff8e77..fab11bb96968 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_delete.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="f2669dff-5f08-45dd-b857-b2a60b72cdc9", + subscription_id="00000000-1111-2222-3333-444444444444", ) client.distributed_availability_groups.begin_delete( @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py index 3866f48340d0..4df1e48f12c6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_get.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="f2669dff-5f08-45dd-b857-b2a60b72cdc9", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.distributed_availability_groups.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py index 7c5cf95badde..93012e4fb927 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py new file mode 100644 index 000000000000..2c781e755a48 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_set_role.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_set_role( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={"instanceRole": "Primary", "roleChangeType": "Forced"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsSetRole.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py index 62c13e4b68fc..042d28be509c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DistributedAvailabilityGroupsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py index a58aa037c1ba..a5afe27e9ba4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_max.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateOrUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_min.py index 9b3e34fba496..1cf2b78baae4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateOrUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py new file mode 100644 index 000000000000..3ff63b2b15ee --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_serverless_properties.py @@ -0,0 +1,51 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python elastic_pool_create_or_update_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.elastic_pools.begin_create_or_update( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + parameters={ + "location": "Japan East", + "properties": { + "autoPauseDelay": 60, + "minCapacity": 0.5, + "perDatabaseSettings": {"autoPauseDelay": 80, "maxCapacity": 2, "minCapacity": 0}, + }, + "sku": {"capacity": 2, "name": "GP_S_Gen5_2", "tier": "GeneralPurpose"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateOrUpdateServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py index 61cb808451dd..ccf2b9dce054 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_or_update_set_maintenance_configuration.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateSetMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateOrUpdateSetMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_default_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_default_preferred_enclave_type.py index 8e51343ce061..8bb9fff69d70 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_default_preferred_enclave_type.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_default_preferred_enclave_type.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithDefaultPreferredEnclaveType.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateWithDefaultPreferredEnclaveType.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_vbs_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_vbs_preferred_enclave_type.py index 96814d13d4cd..7ecf3e849cd3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_vbs_preferred_enclave_type.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_create_with_vbs_preferred_enclave_type.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithVBSPreferredEnclaveType.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolCreateWithVBSPreferredEnclaveType.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py deleted file mode 100644 index 3582f91c9b25..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py +++ /dev/null @@ -1,43 +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 azure.identity import DefaultAzureCredential -from azure.mgmt.sql import SqlManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-sql -# USAGE - python elastic_pool_database_activity_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = SqlManagementClient( - credential=DefaultAzureCredential(), - subscription_id="9d4e2ad0-e20b-4464-9219-353bded52513", - ) - - response = client.elastic_pool_database_activities.list_by_elastic_pool( - resource_group_name="sqlcrudtest-4673", - server_name="sqlcrudtest-603", - elastic_pool_name="7537", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolDatabaseActivityList.json -if __name__ == "__main__": - main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_delete.py index d0105bd22aea..acdbb84d0901 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get.py index 89a867240730..518f99e6a37a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get_with_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get_with_preferred_enclave_type.py index 4e987ca2f9be..0575d96ab93a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get_with_preferred_enclave_type.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_get_with_preferred_enclave_type.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_list_by_server.py index 57fb8c124d54..83d71ae368c5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_assign_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_assign_maintenance_configuration.py index fe6ac220c495..0898aa4014b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_assign_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_assign_maintenance_configuration.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolUpdateAssignMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateAssignMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_max.py index 2395330e68c8..5e207bf72137 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_max.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_reset_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_reset_maintenance_configuration.py index 9ede9a31ccc7..b0056b3b72d1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_reset_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_reset_maintenance_configuration.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolUpdateResetMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateResetMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py new file mode 100644 index 000000000000..757885421e7f --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_serverless_properties.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python elastic_pool_update_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.elastic_pools.begin_update( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + parameters={ + "properties": { + "autoPauseDelay": 60, + "minCapacity": 0.5, + "perDatabaseSettings": {"autoPauseDelay": 80, "maxCapacity": 2, "minCapacity": 0}, + }, + "sku": {"capacity": 2, "name": "GP_S_Gen5_2", "tier": "GeneralPurpose"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py index c2c8768ceab6..78d9afa57d1f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_default_preferred_enclave_type.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolUpdateWithDefaultPreferredEnclaveType.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateWithDefaultPreferredEnclaveType.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_vbs_preferred_enclave_type.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_vbs_preferred_enclave_type.py index 2b6958a24653..d4f7f58d7e51 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_vbs_preferred_enclave_type.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_update_with_vbs_preferred_enclave_type.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolUpdateWithVBSPreferredEnclaveType.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ElasticPoolUpdateWithVBSPreferredEnclaveType.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault.py index da4d39007c95..7ca4a41659e5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_key_vault.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateKeyVault.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EncryptionProtectorCreateOrUpdateKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_service_managed.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_service_managed.py index 8a506752ef4f..35c3a4512b19 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_service_managed.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_create_or_update_service_managed.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateServiceManaged.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EncryptionProtectorCreateOrUpdateServiceManaged.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get.py index 416e64d747a7..91b7776edfa0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EncryptionProtectorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_list.py index 0218e7d4d479..9c2c47c1fde1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EncryptionProtectorList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_revalidate.py b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_revalidate.py index 55768755af09..95309f90cc42 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_revalidate.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/encryption_protector_revalidate.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorRevalidate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EncryptionProtectorRevalidate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_get.py index d85808a300d9..e380f3bca7bc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EndpointCertificatesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_list_by_instance.py index 06ea4ecf4869..fdc8a4cdb57f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/endpoint_certificates_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/EndpointCertificatesListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py index 26857778948c..4434d34184f0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExportDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py new file mode 100644 index 000000000000..f71509f5f9f6 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python export_database_using_database_extensions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="0ca8cd24-0b47-4ad5-bc7e-d70e35c44adf", + ) + + response = client.database_extensions.begin_create_or_update( + resource_group_name="rg_d1ef9eae-044d-4710-ba59-b82e84ad3157", + server_name="srv_9243d320-ac4e-4f97-8e06-b1167dae5f4c", + database_name="db_7fe424c8-23cf-4ac3-bdc3-e21f424bdb68", + extension_name="Export", + parameters={ + "properties": { + "administratorLogin": "login", + "administratorLoginPassword": "password", + "authenticationType": "Sql", + "operationMode": "Export", + "storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "storageKeyType": "StorageAccessKey", + "storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExportDatabaseUsingDatabaseExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py index c360726e568d..f160e7cc4b8b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabaseWithNetworkIsolation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExportDatabaseWithNetworkIsolation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py index 484d98f1b65f..881b467360e9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseAzureMonitorAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedDatabaseAzureMonitorAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_max.py index 45a3174a00e9..1006a920b670 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_max.py @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_min.py index a43e48fa3a94..95353d4f4e6d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_create_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_get.py index 49f60a8b01ec..5d6298e2665b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_blob_auditing_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_max.py index 7d6f2ad4d3c7..3fbb0fd15ea2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_max.py @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedServerBlobAuditingCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_min.py index 5be96c138cfa..036fdf556877 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_create_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedServerBlobAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_get.py index 37c09e531a4b..fdd8fa3e39fd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/extended_server_blob_auditing_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ExtendedServerBlobAuditingGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py index 27d599fd765a..394c9f253ecb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/FailoverDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py index 2f6fc99c977d..a74d7104e15a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/FailoverElasticPool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverElasticPool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update.py index beb7daf53701..2bade59ecc1e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_create_or_update.py @@ -52,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_delete.py index a9b7cf679926..13cb5d93ae06 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_failover.py index 88f7dace7e9c..ea7bf7b4c11e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_failover.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupFailover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupFailover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_force_failover_allow_data_loss.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_force_failover_allow_data_loss.py index 24df960d05af..8b268d58f1ee 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_force_failover_allow_data_loss.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_force_failover_allow_data_loss.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupForceFailoverAllowDataLoss.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupForceFailoverAllowDataLoss.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_get.py index 63dc7ca29d5e..4b969c0f3a6d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_get.py @@ -31,12 +31,12 @@ def main(): response = client.failover_groups.get( resource_group_name="Default", - server_name="failover-group-primary-server", - failover_group_name="failover-group-test", + server_name="failovergroupprimaryserver", + failover_group_name="failovergrouptest3", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_list.py index 1b0c38a52ff7..5975c1c78c92 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py index aca6172fdbfb..3985a9cb3206 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupTryPlannedBeforeForcedFailover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupTryPlannedBeforeForcedFailover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update.py index 3fb293c37412..db0da5a01227 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/FailoverGroupUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_managed_instance.py index 24f8b6559c88..dd6742b1f619 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_managed_instance.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/FailoverManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_create.py index 6836e5bd7f14..cbd6d8139ec2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_delete.py index 2e0f59421969..72ff59c8bef9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_get.py index 3d525b8784bc..25558655bda1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_list.py index 7a29f4070b04..26732c4f3a4a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_replace.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_replace.py index 45c2d6090f46..6252306e73d3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_replace.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_replace.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleReplace.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleReplace.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_update.py index eb1f687bb3d3..df4168a25a62 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/firewall_rule_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FirewallRuleUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_create_or_update.py index b1f7abe48b8c..8f1704e63119 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_create_or_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GeoBackupPoliciesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_get.py index 9fea1e16d09e..1b38c7d22d04 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GeoBackupPoliciesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_list.py index e17e959b1c6e..14573b683a55 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/geo_backup_policies_list.py @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.geo_backup_policies.list_by_database( + response = client.geo_backup_policies.list( resource_group_name="sqlcrudtest-4799", server_name="sqlcrudtest-5961", database_name="testdw", @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GeoBackupPoliciesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_data_warehouse_user_activities.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_data_warehouse_user_activities.py index ef556167341c..f37f035f9271 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_data_warehouse_user_activities.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_data_warehouse_user_activities.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetDataWarehouseUserActivities.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetDataWarehouseUserActivities.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_extensions.py index 2cd7ea4ba561..c89959a38688 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_extensions.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_extensions.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetDatabaseExtensions.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetDatabaseExtensions.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_usages.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_usages.py index 1e15d100eea9..003f65b73340 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_usages.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_usages.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetDatabaseUsages.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetDatabaseUsages.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py index 1b5838136c41..32c6305e9f99 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetDatabaseWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py index 859428235265..5d180528c64b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetElasticPoolWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py new file mode 100644 index 000000000000..c5e374d61ae7 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_serverless_properties.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python get_elastic_pool_with_serverless_properties.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.elastic_pools.get( + resource_group_name="sqlcrudtest-2369", + server_name="sqlcrudtest-8069", + elastic_pool_name="sqlcrudtest-8102", + ) + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetElasticPoolWithServerlessProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py index 71fe04535a1d..529aee9aed9d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_instance_pool.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetInstancePool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py index fc93f8f7c280..c53638d13985 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_agent.py index 5c6e1c00c41b..e080ff614076 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_agent.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_credential.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_credential.py index 8a64641be748..732714781ac8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_credential.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_credential.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobCredential.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobCredential.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution.py index c3c73057e9ce..af3b7c97a071 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobExecution.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_step.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_step.py index 8fcec1ced544..0872ce7712e9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_step.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_step.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionStep.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobExecutionStep.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_target.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_target.py index 06685247afab..8c87f296387a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_target.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_execution_target.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionTarget.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobExecutionTarget.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py similarity index 83% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py index 73e1c51aa36e..e9c42ca19816 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_private_endpoint.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_get.py + python get_job_private_endpoint.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.service_objectives.get( + response = client.job_private_endpoints.get( resource_group_name="group1", - server_name="sqlcrudtest", - service_objective_name="29dd7459-4a7c-4e56-be22-f0adda49440d", + server_name="server1", + job_agent_name="agent1", + private_endpoint_name="endpoint1", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobPrivateEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py index 4967545777aa..e69e934466df 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_job.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobStepByJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_version.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_version.py index 1008d8a8bfb4..50666d580f0a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_version.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_step_by_version.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByVersion.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobStepByVersion.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_target_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_target_group.py index a722407b746e..a29be2245072 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_target_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_target_group.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobTargetGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_version.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_version.py index 51f069d057b2..5429b7d02547 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_job_version.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_job_version.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobVersion.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetJobVersion.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy.py index f5b85619fe19..082ae70525f3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetListManagedShortTermRetentionPolicy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy_restorable_dropped.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy_restorable_dropped.py index 9f061ebc9987..63228c48e967 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy_restorable_dropped.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_list_managed_short_term_retention_policy_restorable_dropped.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicyRestorableDropped.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetListManagedShortTermRetentionPolicyRestorableDropped.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_window_options.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_window_options.py index ac9a65dfad37..dab8a7ed0fb5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_window_options.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_window_options.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetMaintenanceWindowOptions.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetMaintenanceWindowOptions.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_windows.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_windows.py index 0a323beb8df9..c63e40d90ae9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_windows.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_maintenance_windows.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetMaintenanceWindows.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetMaintenanceWindows.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_instance_operation.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_instance_operation.py index 0a86b623f1fb..1cefcd4b8383 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_instance_operation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_instance_operation.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedInstanceOperation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetManagedInstanceOperation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy.py index e283f5a2c9fd..e1d857fcab29 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetManagedShortTermRetentionPolicy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy_restorable_dropped.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy_restorable_dropped.py index 489df0a0f1e5..be39aee1a71c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy_restorable_dropped.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_managed_short_term_retention_policy_restorable_dropped.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_recoverable_managed_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_recoverable_managed_database.py index 8cda3453abf0..311472b2ef05 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_recoverable_managed_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_recoverable_managed_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetRecoverableManagedDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetRecoverableManagedDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database.py index 9ca8c2c16f52..c3cafadb2a07 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetRestorableDroppedDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database_with_expand_equals_keys.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database_with_expand_equals_keys.py index e1a708dbdef4..f8602f39f167 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database_with_expand_equals_keys.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_database_with_expand_equals_keys.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_managed_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_managed_database.py index aebe96b334c1..328eb27d5542 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_managed_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_restorable_dropped_managed_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/GetRestorableDroppedManagedDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetRestorableDroppedManagedDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_short_term_retention_policy.py index 0fb6e882f1d1..b66e60eff6d9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_short_term_retention_policy.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetShortTermRetentionPolicy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py index 11b40a122bea..1c5479953773 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetVCoreDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py index 21937b9b6d19..4f6aea56b0f6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py index 799a0ddb263f..2c652545f372 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetVCoreDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py index 5fd75aafa4c4..c7ab45631dab 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py index e7468437a3c3..a8ba1a3730c7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetWorkloadClassifier.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier_list.py index 310b5bd9b53f..20010504ed6d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier_list.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifierList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetWorkloadClassifierList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group.py index 9955c76c4cbd..ab5d20a891fd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetWorkloadGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group_list.py index 96b2e55f21e5..61e1162105ca 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_group_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroupList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetWorkloadGroupList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_create_or_update_set_high_availability_replica_count.py b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_create_or_update_set_high_availability_replica_count.py index 9af7c15cfd53..a6a2b359517d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_create_or_update_set_high_availability_replica_count.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_create_or_update_set_high_availability_replica_count.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolCreateOrUpdateSetHighAvailabilityReplicaCount.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/HyperscaleElasticPoolCreateOrUpdateSetHighAvailabilityReplicaCount.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_get.py index e2ad9be2e3d8..55c1970c324e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/HyperscaleElasticPoolGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_update_set_high_availability_replica_count.py b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_update_set_high_availability_replica_count.py index 841e10b8d1d7..da4f40dcfbd2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_update_set_high_availability_replica_count.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/hyperscale_elastic_pool_update_set_high_availability_replica_count.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolUpdateSetHighAvailabilityReplicaCount.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/HyperscaleElasticPoolUpdateSetHighAvailabilityReplicaCount.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py index 95e36574cdc7..a2972bc4d2f9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ImportDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py new file mode 100644 index 000000000000..f5f74bcde745 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python import_database_using_database_extensions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="17ca4d13-bf7d-4c33-a60e-b87a2820a325", + ) + + response = client.database_extensions.begin_create_or_update( + resource_group_name="rg_062866bf-c4f4-41f9-abf0-b59132ca7924", + server_name="srv_2d6be2d2-26c8-4930-8fb6-82a5e95e0e82", + database_name="db_2a47e946-e414-4c00-94ac-ed886bb78302", + extension_name="Import", + parameters={ + "properties": { + "administratorLogin": "login", + "administratorLoginPassword": "password", + "authenticationType": "Sql", + "operationMode": "Import", + "storageKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "storageKeyType": "StorageAccessKey", + "storageUri": "https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ImportDatabaseUsingDatabaseExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py index 5bfb963461bd..b877a6ba2688 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabaseWithNetworkIsolation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ImportDatabaseWithNetworkIsolation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py index 1f2bb5b5af2d..c0502fe392d9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ImportNewDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ImportNewDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_network_isolation.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_network_isolation.py index 070f3961af53..d646b7492393 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_network_isolation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database_with_network_isolation.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ImportNewDatabaseWithNetworkIsolation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ImportNewDatabaseWithNetworkIsolation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/inaccessible_managed_database_list_by_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/inaccessible_managed_database_list_by_managed_instance.py index 10039579266f..720b24da9e15 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/inaccessible_managed_database_list_by_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/inaccessible_managed_database_list_by_managed_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/InaccessibleManagedDatabaseListByManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InaccessibleManagedDatabaseListByManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_create_or_update.py index ac65503c20e0..d9f862c1caa7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_create_or_update.py @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_delete.py index c0a23c9d8722..a5f90ce0d772 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_failover.py index f27ebd91f85a..31f661db3218 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_failover.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupFailover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupFailover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_force_failover_allow_data_loss.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_force_failover_allow_data_loss.py index ddb4844c3b9e..faf9c9a796b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_force_failover_allow_data_loss.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_force_failover_allow_data_loss.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupForceFailoverAllowDataLoss.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupForceFailoverAllowDataLoss.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_get.py index 89a879d0d617..8b34fa495e66 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_list.py index bfe71fba768c..21f86957cd9e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/instance_failover_group_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/InstanceFailoverGroupList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_create.py index 486d0b050f25..cc37b4412250 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_create.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/IPv6FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_delete.py index fa15bfeeba47..613179a2593b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/IPv6FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_get.py index 3e718510eeb1..e0e4aeb5301c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/IPv6FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_list.py index 0933084bd451..1ae703503546 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/IPv6FirewallRuleList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_update.py index 87ce443a489e..e7951d3cdb63 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ipv6_firewall_rule_update.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/IPv6FirewallRuleUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_disable.py b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_disable.py index b4a0f44e5654..6953364d00f9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_disable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_disable.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsDisable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LedgerDigestUploadsDisable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_enable.py b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_enable.py index 9e041ac8f7d8..693dbf04c390 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_enable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_enable.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsEnable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LedgerDigestUploadsEnable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_get.py index 9ce18d9956ae..dcde70ba233c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LedgerDigestUploadsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_list.py index 2da2c3940395..d7fddc93a07d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/ledger_digest_uploads_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LedgerDigestUploadsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_data_warehouse_user_activities.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_data_warehouse_user_activities.py index 85d3c9bf46a4..d4c88dcff500 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_data_warehouse_user_activities.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_data_warehouse_user_activities.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListDataWarehouseUserActivities.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListDataWarehouseUserActivities.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_database_extensions.py index b5c6b76b33cb..8c155d9c2d7b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_database_extensions.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_database_extensions.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListDatabaseExtensions.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListDatabaseExtensions.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_database_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_database_operations.py index 078840b6318e..766c17182f85 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_database_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_database_operations.py @@ -30,14 +30,14 @@ def main(): ) response = client.database_operations.list_by_database( - resource_group_name="sqlcrudtest-7398", - server_name="sqlcrudtest-4645", + resource_group_name="Default-SQL-SouthEastAsia", + server_name="testsvr", database_name="testdb", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListDatabaseOperations.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListDatabaseOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py index 180ba950c601..c5b87e10a3f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListDatabasesByElasticPool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListDatabasesByElasticPool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py index 11205104afdd..b0f7459755b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListElasticPoolOperations.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListElasticPoolOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage.py index 42049efff7e5..57b3f549993b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsage.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolUsage.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage_expanded.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage_expanded.py index 925f2f241a5c..16f90bcc005f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage_expanded.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pool_usage_expanded.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsageExpanded.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolUsageExpanded.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_resource_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_resource_group.py index a28c2a5129aa..382f9e2f5951 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_resource_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListInstancePoolsByResourceGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_subscription_id.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_subscription_id.py index d522df008515..b5c167745240 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_subscription_id.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_instance_pools_by_subscription_id.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListInstancePoolsBySubscriptionId.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsBySubscriptionId.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_agents_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_agents_by_server.py index 068aba00fac2..ca4700972654 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_agents_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_agents_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobAgentsByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobAgentsByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_credentials_by_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_credentials_by_agent.py index 6fc02f34782c..e43545344208 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_credentials_by_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_credentials_by_agent.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobCredentialsByAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobCredentialsByAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_steps.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_steps.py index ad2f1ee0e4ee..cf54c438bf0c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_steps.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_steps.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionSteps.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionSteps.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_execution.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_execution.py index 76c4316a0d29..f74269d1ce3a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_execution.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_execution.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByExecution.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionTargetsByExecution.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_step.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_step.py index 077dd593bc1e..af2365f8cbfb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_step.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_execution_targets_by_step.py @@ -41,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByStep.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionTargetsByStep.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent.py index 0d898ccf63ae..d860c9bb4ee8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionsByAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionsByAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent_with_filter.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent_with_filter.py index 633d95013cf0..aa94bc20ad34 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent_with_filter.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_agent_with_filter.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionsByAgentWithFilter.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionsByAgentWithFilter.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_job.py index 8d43c2f70c3b..93d891cec593 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_executions_by_job.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionsByJob.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobExecutionsByJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py similarity index 84% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py index 17758295e5eb..0a541d49babc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_private_endpoints_by_agent.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_list.py + python list_job_private_endpoints_by_agent.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.service_objectives.list_by_server( + response = client.job_private_endpoints.list_by_agent( resource_group_name="group1", - server_name="sqlcrudtest", + server_name="server1", + job_agent_name="agent1", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobPrivateEndpointsByAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py index 91aa98ef1197..e58fa2b7afc5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_job.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByJob.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobStepsByJob.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_version.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_version.py index f7761109d049..c7f5d81aa684 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_version.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_steps_by_version.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByVersion.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobStepsByVersion.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_target_groups.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_target_groups.py index a1a0122c94ef..15ba5ab04bae 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_target_groups.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_target_groups.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobTargetGroups.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobTargetGroups.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_versions.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_versions.py index d30d32008374..1f772e474c47 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_job_versions.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_job_versions.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobVersions.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobVersions.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_jobs_by_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_jobs_by_agent.py index 752e525381dc..8c29f03a3971 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_jobs_by_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_jobs_by_agent.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobsByAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListJobsByAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_managed_instance_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_managed_instance_operations.py index f3446f9d75ec..0d7246c2b6b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_managed_instance_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_managed_instance_operations.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListManagedInstanceOperations.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListManagedInstanceOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py new file mode 100644 index 000000000000..902dfe353546 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py @@ -0,0 +1,39 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python list_operations.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_outbound_network_dependencies_by_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_outbound_network_dependencies_by_managed_instance.py index 48fdf6081bf7..9f745d3cd52a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_outbound_network_dependencies_by_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_outbound_network_dependencies_by_managed_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListOutboundNetworkDependenciesByManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListOutboundNetworkDependenciesByManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_recoverable_managed_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_recoverable_managed_databases_by_server.py index 39ccbcef1eef..b65678f2ec43 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_recoverable_managed_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_recoverable_managed_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListRecoverableManagedDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListRecoverableManagedDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_restorable_dropped_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_restorable_dropped_databases_by_server.py index 4539ede5dc15..4d6b635419d4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_restorable_dropped_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_restorable_dropped_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListRestorableDroppedDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListRestorableDroppedDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_server_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_server_operations.py index dcf6d922189b..0e7973fee586 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_server_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_server_operations.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListServerOperations.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListServerOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_short_term_retention_policies_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_short_term_retention_policies_by_database.py index 15df3fdd5bdb..b585f321c593 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_short_term_retention_policies_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_short_term_retention_policies_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListShortTermRetentionPoliciesByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListShortTermRetentionPoliciesByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py index 99137f679e33..2fab3a40ad61 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListVCoreDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py index 0aebfc0cad19..f66b2915df32 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py index bcc793701585..de2ac1180933 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py index 06c607b4b823..7fdd96fc6e1d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/LocationCapabilityListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LocationCapabilityListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_copy.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_copy.py index 3ce178f89563..a2231c9943ca 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_copy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_copy.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupCopy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupCopy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_delete.py index bf884e947bc4..7e848555beb3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_delete.py @@ -33,10 +33,10 @@ def main(): location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Hot", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_get.py index a79f1edc9af7..997b956343f1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_get.py @@ -33,11 +33,11 @@ def main(): location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_database.py index d141a35afc39..583f81dcadee 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_location.py index cb43db8273ce..66bc026c4203 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_location.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_server.py index 273c27d28c0a..78092c5f6ddd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_update.py index de1bf1e63641..d71b51de6766 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_backup_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/LongTermRetentionBackupUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py index 7630f27b819d..2ef89f50d1b1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_get.py index 4cf433ca2297..172ec8851c1f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/LongTermRetentionPolicyGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_list_by_database.py index 943ff1076761..692376d3d08f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/LongTermRetentionPolicyListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_max.py index 463d519330a9..1f5133f4e061 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_max.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedColumnsListByDatabaseMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedColumnsListByDatabaseMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_min.py index 519f4a75da2f..520d589e9caa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_columns_list_by_database_min.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedColumnsListByDatabaseMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedColumnsListByDatabaseMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_max.py index 8902e446789f..80b7b5b4f8c7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_max.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_min.py index 25156e132d98..d529afd6659c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_create_min.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_get.py index c470028291de..273fa2e9ac84 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_list_by_database.py index 979cefc81963..f9740c290f27 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_advanced_threat_protection_settings_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_cancel_move.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_cancel_move.py index 0b62cb511e94..98df29f1a2a7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_cancel_move.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_cancel_move.py @@ -39,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCancelMove.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCancelMove.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_get.py index c637602e7acc..c655cdb1d3c8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_get.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseColumnGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_list_by_table.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_list_by_table.py index 7c205120a9da..066f682186cd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_list_by_table.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_list_by_table.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnListByTable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseColumnListByTable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_create.py index cac7da24ecba..913694850079 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_create.py @@ -38,6 +38,7 @@ def main(): column_name="myColumn", parameters={ "properties": { + "clientClassificationSource": "Native", "informationType": "PhoneNumber", "informationTypeId": "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", "labelId": "bf91e08c-f4f0-478a-b016-25164b2a65ff", @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnSensitivityLabelCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseColumnSensitivityLabelCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_delete.py index 91d48d4537b0..18db7b00efa0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_delete.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnSensitivityLabelDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseColumnSensitivityLabelDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_get.py index f03ddf6c4404..99b1750792e2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_column_sensitivity_label_get.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnSensitivityLabelGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseColumnSensitivityLabelGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_external_restore.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_external_restore.py index 3e70339b1581..9ab3c7132143 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_external_restore.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_external_restore.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCompleteExternalRestore.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCompleteExternalRestore.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_move.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_move.py index 7a53e735cdad..5c14ae024128 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_move.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_complete_move.py @@ -39,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCompleteMove.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCompleteMove.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_cross_subscription_point_in_time_restore.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_cross_subscription_point_in_time_restore.py index 8240435102c9..811b36b4959f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_cross_subscription_point_in_time_restore.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_cross_subscription_point_in_time_restore.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_max.py index dc050e6b4eb8..ff9904cbbf48 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_max.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_min.py index d7a032526ccf..a27dff458c96 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_point_in_time_restore.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_point_in_time_restore.py index f22ccb773ca7..af6db4e216b3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_point_in_time_restore.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_point_in_time_restore.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreatePointInTimeRestore.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreatePointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_recovery.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_recovery.py index c45d4fb8eaaf..453e58eeed2a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_recovery.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_recovery.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRecovery.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateRecovery.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup.py index 771931801695..ecbe6de9d6d9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup_managed_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup_managed_identity.py index 24f65ce035b4..680ffa0900ab 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup_managed_identity.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_external_backup_managed_identity.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_ltr_backup.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_ltr_backup.py index aa37275264fb..d7c2951566ed 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_ltr_backup.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_create_restore_ltr_backup.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreLtrBackup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseCreateRestoreLtrBackup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_delete.py index bb7043b7f774..2cd0be0cb934 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_get.py index 2dbf38efd259..298006517454 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_list_by_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_list_by_managed_instance.py index 093c613d0a4f..ba0e61e41b99 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_list_by_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_list_by_managed_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseListByManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseListByManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_get.py index b5d3aff33840..418b2cd4c86c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedDatabaseMoveOperationResultGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseMoveOperationResultGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list.py index 84ddba0d73c1..6bde7ebc20ef 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedDatabaseMoveOperationResultList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseMoveOperationResultList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_last_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_last_operations.py index 8fcfc11cceb0..2b28e64960cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_last_operations.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_last_operations.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedDatabaseMoveOperationResultListLastOperations.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseMoveOperationResultListLastOperations.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_max.py index 2154763ffa41..4a6bf2bdb9c6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_move_operation_result_list_max.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedDatabaseMoveOperationResultListMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseMoveOperationResultListMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_disable.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_disable.py index 3e01ebe24ba8..5bfe330099b5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_disable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_disable.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelDisable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelDisable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_enable.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_enable.py index 214b79276cdd..e3e2ef8a0302 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_enable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_recommended_column_sensitivity_label_enable.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelEnable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseRecommendedColumnSensitivityLabelEnable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_restore_details.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_restore_details.py index 798e778dcd90..a6ce665b288b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_restore_details.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_restore_details.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedDatabaseRestoreDetails.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseRestoreDetails.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_get.py index 408d38bb55e5..34d5fa2ebcb3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSchemaGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_list_by_database.py index 2700a5cf5863..4d81093d3023 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_schema_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSchemaListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_max.py index 77aa6402b5ea..0f79ef823228 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_max.py @@ -33,7 +33,7 @@ def main(): resource_group_name="securityalert-4799", managed_instance_name="securityalert-6440", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", parameters={ "properties": { "disabledAlerts": ["Sql_Injection", "Usage_Anomaly"], @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityAlertCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_min.py index 76421da784a2..01bbbd56189a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_create_min.py @@ -33,12 +33,12 @@ def main(): resource_group_name="securityalert-4799", managed_instance_name="securityalert-6440", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", parameters={"properties": {"state": "Enabled"}}, ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityAlertCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_get.py index 8d52e21ef080..9a23f7b515e3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_get.py @@ -33,11 +33,11 @@ def main(): resource_group_name="securityalert-6852", managed_instance_name="securityalert-2080", database_name="testdb", - security_alert_policy_name="Default", + security_alert_policy_name="default", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityAlertGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_list_by_database.py index df8ef0b51f96..5d9b7975f067 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_alert_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityAlertListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_max.py index c04a72c5a5fe..1644737ffea8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_max.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityEventsGetMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityEventsGetMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_min.py index 54147e6e57e9..6a7e12d4bd52 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_security_events_get_min.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityEventsGetMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSecurityEventsGetMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_current_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_current_update.py index 9ef9bcd8c889..729e32b370b5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_current_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_current_update.py @@ -73,6 +73,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsCurrentUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSensitivityLabelsCurrentUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py similarity index 78% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py index 5ad837baa643..900bd9c0064a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python elastic_pool_metrics_definitions_list.py + python managed_database_sensitivity_labels_list_by_database.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,15 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pools.list_metric_definitions( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - elastic_pool_name="3481", + response = client.managed_database_sensitivity_labels.list_by_database( + resource_group_name="myRG", + managed_instance_name="myManagedInstanceName", + database_name="myDatabase", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSensitivityLabelsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_current.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_current.py index 147f121a38ec..e6dcabab4754 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_current.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_current.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsListByDatabaseCurrent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSensitivityLabelsListByDatabaseCurrent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_recommended.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_recommended.py index 95bcfd87e53c..daba4e92cc6f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_recommended.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database_recommended.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsListByDatabaseRecommended.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSensitivityLabelsListByDatabaseRecommended.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_recommended_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_recommended_update.py index bead3b75387d..cf0cb70e6aaf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_recommended_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_recommended_update.py @@ -43,6 +43,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSensitivityLabelsRecommendedUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseSensitivityLabelsRecommendedUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_max.py index 532217d2c765..0058f700c93d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_max.py @@ -40,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseStartMoveMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseStartMoveMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_min.py index 6c1c10811473..987273ec61ea 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_start_move_min.py @@ -39,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseStartMoveMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseStartMoveMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_get.py index ff6ad300d51a..701e1dbf9c8c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseTableGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_list_by_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_list_by_schema.py index 22cb4f7a9cfe..ede63312a259 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_list_by_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_table_list_by_schema.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableListBySchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseTableListBySchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_max.py index 5cb122b3b182..86a2713a0748 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_max.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_min.py index 000a525f4109..31e031c6b394 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_update_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_max.py index 56eb5ef61597..0717d278b8b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_max.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_min.py index b7af7e0fb0bb..94f3301a355c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_create_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_delete.py index a572275a8634..ac7db0c57994 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_delete.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_get.py index 01df21238fb2..2cf10612415f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_list_by_database.py index 43b6b024b7f3..9f35089c40bb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_create.py index e8ee07e1a814..b25b49d566cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_create.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_delete.py index 2f7ac6a846d6..9f3a8259b23c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_delete.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_get.py index c9aae54fb5af..7cf92240e2d5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_rule_baseline_get.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_export.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_export.py index 47a40871e64a..de1ef2648f1d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_export.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_export.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanExport.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanExport.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_get.py index c918249e0f92..23df96507219 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_list_by_database.py index a8091b377ec5..40a6a7cdf60d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scan_records_list_by_database.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scans_execute.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scans_execute.py index 30972ff47d86..6ba71ca08abe 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scans_execute.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_vulnerability_assessment_scans_execute.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScansExecute.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_create.py index aa981e0be106..886256490b71 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_create.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdministratorCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_delete.py index 163509cfe48e..121f5ab65fc5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdministratorDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_get.py index faa32ffe8665..364b2bcecd0a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdministratorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_list_by_instance.py index b61258c1e8b0..a897c2e4b732 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdministratorListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_update.py index e41ad6a360b0..6ff99a2ccbde 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_administrator_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdministratorUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_max.py index 321fdd3788ca..d58124cd839b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_max.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_min.py index 275c31b12013..e5f7dad06eda 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_get.py index 49fb369db227..3e519793951b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_list_by_instance.py index 867a5f76c4cf..f8e4f8a68413 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_advanced_threat_protection_settings_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_create_or_update.py index 690bbfaff007..3be4a57fa6be 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_create_or_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_delete.py index 57c1f32d167f..fe4a18fa7b9c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAzureADOnlyAuthDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_get.py index cc6a5e978df6..f1664b4a6343 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_list_by_instance.py index 6474dee08898..f2ecc52fbc3f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_azure_ad_only_auth_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceAzureADOnlyAuthListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_max.py index e0401f347476..81a6ca05e7b8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_max.py @@ -45,7 +45,9 @@ def main(): "tenantId": "00000011-1111-2222-2222-123456789111", }, "collation": "SQL_Latin1_General_CP1_CI_AS", + "databaseFormat": "AlwaysUpToDate", "dnsZonePartner": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testinstance", + "hybridSecondaryUsage": "Passive", "instancePoolId": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/instancePools/pool1", "licenseType": "LicenseIncluded", "maintenanceConfigurationId": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1", @@ -66,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_min.py index 4ab8ecbb7b95..025590502aed 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_create_min.py @@ -42,12 +42,12 @@ def main(): "subnetId": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1", "vCores": 8, }, - "sku": {"name": "GP_Gen4", "tier": "GeneralPurpose"}, + "sku": {"name": "GP_Gen5", "tier": "GeneralPurpose"}, }, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_delete.py index 787896b7107c..cebb9a411553 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_delete.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) client.managed_instances.begin_delete( @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_get.py index fbb0d0e45c17..47290df0942f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDtcGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_list.py index 2475b33068ce..580798b47917 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDtcList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_enable_dtc.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_enable_dtc.py index 4637c61cc93b..051a6e434751 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_enable_dtc.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_enable_dtc.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateEnableDtc.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDtcUpdateEnableDtc.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_max.py index 8546f1030713..0407a58a8c25 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_dtc_update_max.py @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceDtcUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_key_vault.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_key_vault.py index 6badd6536128..a298c5c0e02e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_key_vault.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_key_vault.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateKeyVault.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_service_managed.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_service_managed.py index c2215c5e1941..a46088467ccf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_service_managed.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_create_or_update_service_managed.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateServiceManaged.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateServiceManaged.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_get.py index 6350fa9a5d5f..58f3d46b629e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_list.py index feb2633bf0ac..eec113242598 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceEncryptionProtectorList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_revalidate.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_revalidate.py index eb5d1fb29de7..522ebc01fb3e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_revalidate.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_encryption_protector_revalidate.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorRevalidate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceEncryptionProtectorRevalidate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get.py index a6cc7a52d030..0d6cf9c7ff2a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.get( @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py similarity index 81% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py index 072fa1091a30..15a77887263f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_while_updating.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_delete.py + python managed_instance_get_while_updating.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,13 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - client.server_communication_links.delete( - resource_group_name="sqlcrudtest-7398", - server_name="sqlcrudtest-4645", - communication_link_name="link1", + response = client.managed_instances.get( + resource_group_name="testrg", + managed_instance_name="testinstance", ) + print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGetWhileUpdating.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py index 9781d74484ce..4723a9f7ef84 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_get_with_expand_equals_administrators.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.get( @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_create_or_update.py index 22b749aa344e..e87c33880839 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_create_or_update.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_delete.py index 26b986e3661d..ac2149f85f41 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceKeyDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_get.py index 9209545ccebe..f2dbc1b654ff 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceKeyGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_list.py index c2d32974e425..0bd3c2d1234c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_key_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceKeyList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list.py index 49d792656d56..5e5bcb304d08 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list() @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool.py index 92e4153e9679..977a8eaddd7f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list_by_instance_pool( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByInstancePool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool_with_expand_equals_administrators.py index e2ee4fdbee94..3f7755f4359c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_instance_pool_with_expand_equals_administrators.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list_by_instance_pool( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePoolWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByInstancePoolWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group.py index 54289539533c..9d3457643bd7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list_by_resource_group( @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group_with_expand_equals_administrators.py index 2c238e081935..a0b999121c43 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_by_resource_group_with_expand_equals_administrators.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list_by_resource_group( @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroupWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListByResourceGroupWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_with_expand_equals_administrators.py index 90393d47e055..d34c997f8f77 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_list_with_expand_equals_administrators.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.list() @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceListWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_delete.py index 09f172c4b454..bf61136b8982 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_delete.py @@ -33,10 +33,10 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Hot", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_get.py index d5221425b6b7..4e943a60dc0d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_get.py @@ -33,11 +33,11 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_database.py index 431e6db4ec91..290e69ab6bbd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_instance.py index 4413c8444018..54c9160df4d0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location.py index ba7c01d3b31a..b2eabea5a714 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py similarity index 81% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py index 302e9555e80d..36f476bf831e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_backup_list_by_location_max.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python elastic_pool_activity_list.py + python managed_instance_long_term_retention_backup_list_by_location_max.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,15 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pool_activities.list_by_elastic_pool( - resource_group_name="sqlcrudtest-4291", - server_name="sqlcrudtest-6574", - elastic_pool_name="8749", + response = client.long_term_retention_managed_instance_backups.list_by_location( + location_name="japaneast", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolActivityList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByLocationMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py index 2c4f1258d95a..615851e373af 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_create_or_update.py @@ -36,6 +36,7 @@ def main(): policy_name="default", parameters={ "properties": { + "backupStorageAccessTier": "Hot", "monthlyRetention": "P1Y", "weekOfYear": 5, "weeklyRetention": "P1M", @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py new file mode 100644 index 000000000000..4181de0de229 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python managed_instance_long_term_retention_policy_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.managed_instance_long_term_retention_policies.begin_delete( + resource_group_name="testResourceGroup", + managed_instance_name="testInstance", + database_name="testDatabase", + policy_name="default", + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionPolicyDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_get.py index ca162da49d28..5119c7f45c99 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_list_by_database.py index e12106e9ef37..6c38f44f4f7a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceLongTermRetentionPolicyListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_delete.py index bc8d54c50a37..18b837401571 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_get.py index cd1f4c4ed109..a7ef8415f80d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_list.py index 020344fabf39..20d657635046 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_update.py index 75b64727e82e..49ef7227d644 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_endpoint_connection_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_get.py index 3116d6dc76e5..409eaff5aad3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_list.py index 36a27f4fc155..2f9032adf113 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_private_link_resources_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstancePrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_get.py index b870a911d95c..058617f8e3b7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceQueryGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceQueryGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list.py index df30a622451d..2894450ab16b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceQueryStatisticsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceQueryStatisticsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_max.py index 68f586d8cb95..67fa3f3e7b46 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_max.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceQueryStatisticsListMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceQueryStatisticsListMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_min.py index 43c6ffab58ed..39b73f25235f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_query_statistics_list_min.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceQueryStatisticsListMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceQueryStatisticsListMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py new file mode 100644 index 000000000000..cd7aee18eec2 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_refresh_external_governance_status.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python managed_instance_refresh_external_governance_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.managed_instances.begin_refresh_status( + resource_group_name="sqlcrudtest-7398", + managed_instance_name="sqlcrudtest-4645", + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceRefreshExternalGovernanceStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py index 6295d31b73fb..27fdcd7e1619 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_remove_maintenance_configuration.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.begin_update( @@ -34,13 +34,13 @@ def main(): managed_instance_name="testinstance", parameters={ "properties": { - "maintenanceConfigurationId": "/subscriptions/20d7082a-0fc7-4468-82bd-542694d5042b/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default" + "maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default" } }, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceRemoveMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceRemoveMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_tde_certificate.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_tde_certificate.py index 7ea6907d4e4e..28d6072df722 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_tde_certificate.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_tde_certificate.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTdeCertificate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTdeCertificate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_get.py index 44db1246f413..e6291812d0b7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTimeZoneGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_list_by_location.py index 768e4db45fb0..483d4650269a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_time_zone_list_by_location.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTimeZoneListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list.py index 545cb78f0368..298d5a96fd65 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceTopQueriesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_max.py index f777e163e4cb..670289476548 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_max.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceTopQueriesListMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesListMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_min.py index d23c5757233d..70be778d283d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_top_queries_list_min.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceTopQueriesListMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceTopQueriesListMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_max.py index b11b5c06b793..f4d264488b72 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_max.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.begin_update( @@ -36,9 +36,12 @@ def main(): "properties": { "administratorLogin": "dummylogin", "administratorLoginPassword": "PLACEHOLDER", + "authenticationMetadata": "Windows", "collation": "SQL_Latin1_General_CP1_CI_AS", + "databaseFormat": "AlwaysUpToDate", + "hybridSecondaryUsage": "Passive", "licenseType": "BasePrice", - "maintenanceConfigurationId": "/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1", + "maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1", "minimalTlsVersion": "1.2", "proxyOverride": "Redirect", "publicDataEndpointEnabled": False, @@ -46,13 +49,13 @@ def main(): "storageSizeInGB": 448, "vCores": 8, }, - "sku": {"capacity": 8, "name": "GP_Gen4", "tier": "GeneralPurpose"}, + "sku": {"capacity": 8, "name": "GP_Gen5", "tier": "GeneralPurpose"}, "tags": {"tagKey1": "TagValue1"}, }, ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_min.py index 6aa5e16e9857..a5fc7f4e5757 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_update_min.py @@ -26,7 +26,7 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="20D7082A-0FC7-4468-82BD-542694D5042B", + subscription_id="00000000-1111-2222-3333-444444444444", ) response = client.managed_instances.begin_update( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_container_sas_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_container_sas_key_min.py index b39d923ba372..57db5cbe8876 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_container_sas_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_container_sas_key_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateContainerSasKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateContainerSasKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_max.py index e31e7ddd2814..4e02de0e9195 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_max.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_storage_access_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_storage_access_key_min.py index 7549d810eff0..4390a4da71a7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_storage_access_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_create_storage_access_key_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateStorageAccessKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateStorageAccessKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_delete.py index f18004c7b67d..fc0edc39e53a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_get.py index 7ef1dfc3b97a..777a7e6f349e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_list_by_instance.py index ef52c120c721..6e4a2e9a2d2c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_vulnerability_assessment_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedInstanceVulnerabilityAssessmentListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_disable.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_disable.py index 75f04048a3d8..362ad51c06b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_disable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_disable.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsDisable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedLedgerDigestUploadsDisable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_enable.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_enable.py index 13ba7724c590..49a3bf76ae5d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_enable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_enable.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsEnable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedLedgerDigestUploadsEnable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_get.py index f12d515b967b..6e16bbb8ef5e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedLedgerDigestUploadsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_list.py index 7787ebdb1c2a..227899f44376 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_ledger_digest_uploads_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedLedgerDigestUploadsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_acquire.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_acquire.py index eeb3fc5dd675..ce84d94397f3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_acquire.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_acquire.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasAcquire.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerDnsAliasAcquire.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_delete.py index ae7f88b8cbf2..8ffbcb9e9f1f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerDnsAliasDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_get.py index 3fad1ed7d039..921b1aad3dc2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerDnsAliasGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_list.py index 3194c3187813..686e04e5d590 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_dns_alias_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerDnsAliasList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_max.py index 43ec17281379..20ae31bda135 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_max.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerSecurityAlertCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_min.py index ca23c3085148..669f4b885a8b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerSecurityAlertCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_get.py index a58cdb86721c..dee7a3009fa8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerSecurityAlertGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_list_by_instance.py index fe102b893551..05e41a88a99a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_server_security_alert_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedServerSecurityAlertListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_get.py index be16b3a27a75..96845f624725 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedTransparentDataEncryptionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_list.py index 6a9e78ae1bd8..8307a18c21c7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedTransparentDataEncryptionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_update.py index 29d8e871e224..b433252fecb4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_transparent_data_encryption_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ManagedTransparentDataEncryptionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_get.py new file mode 100644 index 000000000000..ed5f4851b3a9 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_get.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python network_security_perimeter_configurations_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.network_security_perimeter_configurations.get( + resource_group_name="sqlcrudtest-7398", + server_name="sqlcrudtest-7398", + nsp_config_name="00000001-2222-3333-4444-111144444444.assoc1", + ) + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/NetworkSecurityPerimeterConfigurationsGet.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_list_by_server.py similarity index 82% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_list_by_server.py index 81af264484b1..b4aa383bb10c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_list_by_server.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_list.py + python network_security_perimeter_configurations_list_by_server.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_communication_links.list_by_server( + response = client.network_security_perimeter_configurations.list_by_server( resource_group_name="sqlcrudtest-7398", - server_name="sqlcrudtest-4645", + server_name="sqlcrudtest-7398", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/NetworkSecurityPerimeterConfigurationsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py similarity index 79% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_create_or_update.py rename to sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py index 49c2103c897d..34a6319c244f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_reconcile.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_create_or_update.py + python network_security_perimeter_configurations_reconcile.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_communication_links.begin_create_or_update( + response = client.network_security_perimeter_configurations.begin_reconcile( resource_group_name="sqlcrudtest-7398", - server_name="sqlcrudtest-4645", - communication_link_name="link1", - parameters={"properties": {"partnerServer": "sqldcrudtest-test"}}, + server_name="sqlcrudtest-7398", + nsp_config_name="00000001-2222-3333-4444-111144444444.assoc1", ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/NetworkSecurityPerimeterConfigurationsReconcile.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_create.py similarity index 84% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_create.py index 6911134744c6..44b8c6116bc3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_create.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_get.py + python outbound_firewall_rule_create.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_communication_links.get( + response = client.outbound_firewall_rules.begin_create_or_update( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", - communication_link_name="link1", - ) + outbound_rule_fqdn="server.database.windows.net", + ).result() print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/OutboundFirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_delete.py index 5d7873106afe..cb0266f78997 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/OutboundFirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_get.py index 5d6aafe2ea61..33d23e995843 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/OutboundFirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_list.py index 6e5274410b84..571cb1f0b837 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/OutboundFirewallRuleList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py index 2a297701b6cb..8c3b414ccab7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py index 591e320d9358..03c5f92a94f7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py index 856593c9ffec..ebb7d14b5e97 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PatchInstancePool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchInstancePool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py index 329a494c8e7f..95c5e409eace 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchVCoreDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py index 0e4f30ed6638..78e3d477df83 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py index 8a0c8d9cc1fb..c3d76465ed6c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py index 1f25f62ee858..fce7dd0d3842 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py index b3841eb4e899..3455a1f628ab 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PauseDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PauseDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py index 25257f7fbbc9..5e313dc17cea 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_get.py index e880d0e9d0ee..7329224e92ea 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_list.py index f25cfce6728d..b8e5ce96f82d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_update.py index eaac48099db1..1801246bd914 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_update.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_get.py index b8d8643db3ab..95ff38c3744c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_list.py index 24335380ab56..2863768437f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/private_link_resources_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_disable.py b/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_disable.py index 729f31635410..637dd6a325e7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_disable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_disable.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/RecommendedColumnSensitivityLabelDisable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RecommendedColumnSensitivityLabelDisable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_enable.py b/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_enable.py index 4f87fa613e12..a6350b04a67f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_enable.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/recommended_column_sensitivity_label_enable.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/RecommendedColumnSensitivityLabelEnable.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RecommendedColumnSensitivityLabelEnable.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get.py index f6cf32abb685..c72466908211 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RecoverableDatabaseGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get_with_expand_equals_keys.py b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get_with_expand_equals_keys.py index 5a81540bfa1b..b41a81abb05f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get_with_expand_equals_keys.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_get_with_expand_equals_keys.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGetWithExpandEqualsKeys.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RecoverableDatabaseGetWithExpandEqualsKeys.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_list.py index 2b331b5aa356..c83adf489a5a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/recoverable_database_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RecoverableDatabaseList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status.py b/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status.py index 549b0d96e8e6..b3c487eff847 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RefreshExternalGovernanceStatus.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RefreshExternalGovernanceStatus.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py index 2784b848da0e..377e48162f96 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/RenameDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RenameDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py index 8d8f4adfefb5..70b60019e688 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover.py index 8d643bad349b..2a1baa6aafb4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkFailover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkFailover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover_allow_data_loss.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover_allow_data_loss.py index eb50621580ae..7fa8a8755a58 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover_allow_data_loss.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_failover_allow_data_loss.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkFailoverAllowDataLoss.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkFailoverAllowDataLoss.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_get.py index 5060806ba784..6a99ec9c88c9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_database.py index 618498b71c16..a35c8786d997 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_server.py index 09882b8834fd..7b36be151802 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ReplicationLinkListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py new file mode 100644 index 000000000000..f4ee9ec9a836 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_change_long_term_retention_backup_access_tier.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python resource_group_based_change_long_term_retention_backup_access_tier.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.long_term_retention_backups.begin_change_access_tier_by_resource_group( + resource_group_name="resourceGroupName", + location_name="japaneast", + long_term_retention_server_name="serverName", + long_term_retention_database_name="databaseName", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", + parameters={"backupStorageAccessTier": "Hot", "operationMode": "Copy"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedChangeLongTermRetentionBackupAccessTier.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_copy.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_copy.py index cfd3b915770e..80e16d284809 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_copy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_copy.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupCopy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupCopy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_delete.py index c09ce56b1260..18c59570f03a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_delete.py @@ -34,10 +34,10 @@ def main(): location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_get.py index b2457e4b29a6..d5ef74786584 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_get.py @@ -34,11 +34,11 @@ def main(): location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_database.py index b3f2277cb22d..908b4ef96dad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_database.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_location.py index 34bb47745d2d..dba6e5b9d5df 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_location.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_server.py index b4245488a95c..bac648b23e65 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_list_by_server.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_update.py index 1d299567f1ca..ad8d89a49be8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_long_term_retention_backup_update.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_delete.py index d82e69790ab4..232031f197ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_delete.py @@ -34,10 +34,10 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_get.py index 1133a80ac462..1ba7ddff4d65 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_get.py @@ -34,11 +34,11 @@ def main(): location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", - backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", + backup_name="55555555-6666-7777-8888-999999999999;131637960820000000;Archive", ) print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_database.py index 629de1d05396..f8e6d308f43a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_database.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_instance.py index 208b00843521..08d31b285417 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_instance.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location.py index 2045aa8431d1..ce7e0a600c14 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py new file mode 100644 index 000000000000..ffa1543b4ac4 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python resource_group_based_managed_instance_long_term_retention_backup_list_by_location_max.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.long_term_retention_managed_instance_backups.list_by_resource_group_location( + resource_group_name="testResourceGroup", + location_name="japaneast", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocationMax.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/restorable_dropped_managed_database_list_by_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/restorable_dropped_managed_database_list_by_managed_instance.py index 469ffe52f556..5418009c9259 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/restorable_dropped_managed_database_list_by_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/restorable_dropped_managed_database_list_by_managed_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/RestorableDroppedManagedDatabaseListByManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/RestorableDroppedManagedDatabaseListByManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py index 13f0f471607e..0f7bf813b670 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ResumeDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResumeDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py index 74180f788f2c..36073039dc6a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py @@ -75,6 +75,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsCurrentUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SensitivityLabelsCurrentUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_definitions_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py similarity index 82% rename from sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_definitions_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py index e7be2d8528fe..5b2edcb8362e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_definitions_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python database_metrics_definitions_list.py + python sensitivity_labels_list_by_database.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,15 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.databases.list_metric_definitions( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - database_name="3481", + response = client.sensitivity_labels.list_by_database( + resource_group_name="myRG", + server_name="myServer", + database_name="myDatabase", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsDefinitionsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SensitivityLabelsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_current.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_current.py index 2c856a12ecba..70cb87a18fc0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_current.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_current.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceCurrent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceCurrent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_recommended.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_recommended.py index 533b083be45b..be52c9fbc8ff 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_recommended.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_list_by_database_with_source_recommended.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceRecommended.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceRecommended.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_recommended_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_recommended_update.py index cf067f8df378..09d494280577 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_recommended_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_recommended_update.py @@ -43,6 +43,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsRecommendedUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SensitivityLabelsRecommendedUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_max.py index 44aa3bd1058f..3d44dc8153e6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_max.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_min.py index 6c0235f2a980..28da55118a7b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_get.py index 2df5b6a5f917..456cc6957aeb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_list_by_server.py index 045bdb532b67..88efa050168b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advanced_threat_protection_settings_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvancedThreatProtectionSettingsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_get.py index fb77969f4bc9..b100a8ec163b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvisorGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_list.py index af876baf5f9c..909e39d95022 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_list.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvisorList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_update.py index f242f587472d..cc181414a8d7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_advisor_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAdvisorUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_auditing_settings_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_auditing_settings_list.py index 76d255fc5ea0..9100d42d889c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_auditing_settings_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_auditing_settings_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAuditingSettingsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAuditingSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_get.py index 2d3a423ce7c8..a8f24b5056fb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAutomaticTuningGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAutomaticTuningGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_max.py index f3ae312ad718..e85445132b6f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_max.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAutomaticTuningUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAutomaticTuningUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_min.py index 866ff21c70e7..e6f9b18c91f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_automatic_tuning_update_min.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAutomaticTuningUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerAutomaticTuningUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_max.py index a5166688c9b8..3f09159d7284 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_max.py @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerBlobAuditingCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_min.py index 932fbb9892c6..42c265e30160 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_create_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerBlobAuditingCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_get.py index 53afba713545..b966352aad14 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_blob_auditing_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerBlobAuditingGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_get.py index 9cf4fd777daa..3c04527a6757 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConfigurationOptionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_list.py index 7161d79e97d8..7a95ba863aad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConfigurationOptionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_update.py index 01a4be920b1d..b92321812588 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_configuration_option_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConfigurationOptionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_get.py index 05d1d8fedada..bccf3dd07a1c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConnectionPoliciesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_list.py index 1eee82775806..1056826340e3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConnectionPoliciesList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_update.py index 40a94c8903c8..2510d553fd12 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_connection_policies_update.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerConnectionPoliciesUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py index af7e191c8942..e72d447f9fda 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py @@ -44,6 +44,7 @@ def main(): "sid": "00000011-1111-2222-2222-123456789111", "tenantId": "00000011-1111-2222-2222-123456789111", }, + "isIPv6Enabled": "Enabled", "publicNetworkAccess": "Enabled", "restrictOutboundNetworkAccess": "Enabled", }, @@ -52,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py index 31c147f52a0f..5e2ed9cda93b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_max.py index 756471367bf4..ce6e1cd71ce7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_max.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDevOpsAuditCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_min.py index c23d4053d4ee..2dc0fc44dfdc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_create_min.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDevOpsAuditCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_get.py index 2530b8f26a08..9961c5e88ddf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDevOpsAuditGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_list.py index f69d056281df..80149bc30c84 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dev_ops_audit_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDevOpsAuditList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_acquire.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_acquire.py index b9250a6a3fbd..0378b158d8b5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_acquire.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_acquire.py @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasAcquire.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDnsAliasAcquire.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_create_or_update.py index da0092256d68..f6b976e86042 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_create_or_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDnsAliasCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_delete.py index 262eec2beff0..f0e6af68dd20 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDnsAliasDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_get.py index e395046e5115..0777818fa0b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDnsAliasGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_list.py index ea3eb7e9d274..4dbb56bee6e5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_dns_alias_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDnsAliasList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_extended_auditing_settings_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_extended_auditing_settings_list.py index fe888366408e..514c891e0c3e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_extended_auditing_settings_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_extended_auditing_settings_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerExtendedAuditingSettingsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerExtendedAuditingSettingsList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py index 7a7ce546a9c6..f9691a0d2d6f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_get_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_get_with_expand_equals_administrators.py index ae06f2da6cb5..478a13b1baa3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_get_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_get_with_expand_equals_administrators.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update.py index f37e45cf854f..7b67dbfea415 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_create_or_update.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerKeyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_delete.py index cfb1f4088b10..2729a2fe961f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerKeyDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_get.py index bfb6ce03fdc5..e5135b89d847 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerKeyGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_list.py index 4f51e7df04a1..ea41abf68271 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_key_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_key_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerKeyList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py index 3a17427bdd6d..ffa86c96e1ff 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group.py index 33df2b4bd4de..fda6343c2547 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerListByResourceGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group_with_expand_equals_administrators.py index d2732c19a5b8..9b2377f5b009 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_by_resource_group_with_expand_equals_administrators.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerListByResourceGroupWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroupWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_with_expand_equals_administrators.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_with_expand_equals_administrators.py index 6377239fe6cf..0f9e2848b545 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_list_with_expand_equals_administrators.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_list_with_expand_equals_administrators.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerListWithExpandEqualsAdministrators.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListWithExpandEqualsAdministrators.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_recommended_action_list_expand.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_recommended_action_list_expand.py index 7cfb2c308871..00d2ed907e66 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_recommended_action_list_expand.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_recommended_action_list_expand.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerRecommendedActionListExpand.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerRecommendedActionListExpand.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_max.py index 7685267bfe4e..bc519ccaa238 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_max.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerSecurityAlertsCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_min.py index 58fafd057c0e..de518ebc95b9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_create_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerSecurityAlertsCreateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_get.py index 58ab4b119436..5d7a806ca508 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerSecurityAlertsGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_list_by_server.py index 99413f1f6b99..947c642f0f22 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_security_alerts_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerSecurityAlertsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_create.py index 20581b93b267..58e7e228ecc5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustCertificatesCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_delete.py index b3c7fdfdc15c..4851007e1c6b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustCertificatesDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_get.py index 99d273a476c7..6698bc350feb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustCertificatesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_list_by_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_list_by_instance.py index 26d98f824abe..a6bcb86038ad 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_list_by_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_certificates_list_by_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesListByInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustCertificatesListByInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_create.py index 2b4d44dffbab..e231f2294796 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_create.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustGroupCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_delete.py index 68d80d3c7741..594220729a62 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustGroupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_get.py index 5cdb873900c3..737e75325a04 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustGroupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list.py index 2da1842e8ea3..587105e22554 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustGroupList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list_by_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list_by_managed_instance.py index 59c0d1e910b0..e2035de485de 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list_by_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_trust_group_list_by_managed_instance.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupListByManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerTrustGroupListByManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py index 5460e9e91e00..fbc2d8164df7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py @@ -36,6 +36,7 @@ def main(): "properties": { "administratorLogin": "dummylogin", "administratorLoginPassword": "placeholder", + "isIPv6Enabled": "Enabled", "publicNetworkAccess": "Disabled", "restrictOutboundNetworkAccess": "Enabled", } @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_usage_metrics_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_usage_list.py similarity index 93% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_usage_metrics_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/server_usage_list.py index 196ac93b31f0..fa9ec26f674d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_usage_metrics_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_usage_list.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_usage_metrics_list.py + python server_usage_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ServerUsageMetricsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerUsageList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_container_sas_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_container_sas_key_min.py index 86fbbc6d85ce..c480f29cbba2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_container_sas_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_container_sas_key_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateContainerSasKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentCreateContainerSasKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_max.py index 5671d8bc63a0..0a7c4ff5109b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_max.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentCreateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_storage_access_key_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_storage_access_key_min.py index afdf46ef8b8d..94a71e56fbae 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_storage_access_key_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_create_storage_access_key_min.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_delete.py index d88fd2a45c2f..2d8a9d9321c7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_get.py index 7eaf89a6a8a3..391d8771c53d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_list_by_server.py index 0b721642c197..685a37584db3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_vulnerability_assessment_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerVulnerabilityAssessmentListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_get.py index 3c2da6291c3f..e3e12031a227 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlAgentConfigurationGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlAgentConfigurationGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_put.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_put.py index 9680488f5c3d..154808d043ee 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_put.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_agent_configuration_put.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlAgentConfigurationPut.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlAgentConfigurationPut.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_tde_certificate_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_tde_certificate_create.py index cca97efabaed..1ffe8754a289 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_tde_certificate_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_tde_certificate_create.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlTdeCertificateCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlTdeCertificateCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add.py index 1b40027b4000..bd423515693c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAdd.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentBaselineAdd.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add_latest.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add_latest.py index 91daf8b04098..e326e5ee0f17 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add_latest.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_add_latest.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAddLatest.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentBaselineAddLatest.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_get.py index 1c4b963bd9b3..0cb879d8a5ba 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py index ca50851d9f16..4fea6f162909 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_baseline_list_by_sql_vulnerability_assessment.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_create.py index 3817ee4d851f..87bcc6040a3f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_delete.py index 5460cac474fb..351abdd0085d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_get.py index 6b69c0e0be55..83b3014686d3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_by_server.py index f7b31184bac3..547a3cc8ab4d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_scans_results.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_scans_results.py index e719887e2d53..8ce51246c75a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_scans_results.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_list_scans_results.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListScansResults.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentListScansResults.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_create.py index ca3c4951252d..c6375dda0f10 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_create.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_delete.py index 62d39d1289ea..4d2207269397 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_delete.py @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_get.py index f8d06bf1a1cf..8e4c674dc263 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_list_by_baseline.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_list_by_baseline.py index cfc4c9a39559..700985a34b68 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_list_by_baseline.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_rule_baseline_list_by_baseline.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineListByBaseline.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineListByBaseline.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan.py index 3b2fb927653a..4f3cbbaf0990 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScan.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentScan.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan_records_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan_records_list_by_database.py index 03465a9fd1c4..004581cd3c7c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan_records_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scan_records_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScanRecordsListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentScanRecordsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_execute.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_execute.py index ab1a2024ee19..637374b83859 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_execute.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_execute.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansExecute.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentScansExecute.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_results.py b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_results.py index 81bde1e99009..29b71336877d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_results.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sql_vulnerability_assessment_scans_results.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansResults.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SqlVulnerabilityAssessmentScansResults.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_managed_instance.py index be359faf7a5d..51883139dd3b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_managed_instance.py @@ -29,12 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - client.managed_instances.begin_start( + response = client.managed_instances.begin_start( resource_group_name="startrg", managed_instance_name="mitostart", ).result() + print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_max.py index 89755a7be20e..f060f4457720 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_max.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_max.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_min.py index f4cbaa9d0d70..f3f8414a5adf 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_create_or_update_min.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_delete.py index c27f17e28a32..45ffece567cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartStopManagedInstanceScheduleDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_get.py index 54a5c3c48876..867d7ba73d06 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartStopManagedInstanceScheduleGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_list.py index 6ad618beea22..a5a7b9867ca9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/start_stop_managed_instance_schedule_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StartStopManagedInstanceScheduleList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/stop_managed_instance.py b/sdk/sql/azure-mgmt-sql/generated_samples/stop_managed_instance.py index 9da57e70505a..3f9e7257db43 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/stop_managed_instance.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/stop_managed_instance.py @@ -29,12 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - client.managed_instances.begin_stop( + response = client.managed_instances.begin_stop( resource_group_name="stoprg", managed_instance_name="mitostop", ).result() + print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StopManagedInstance.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/StopManagedInstance.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_get.py index 5e43181a2d3c..b689169b51a2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SubscriptionUsageGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_list_by_location.py index 3b1486f80e5b..aad555ee09fd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_list_by_location.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/subscription_usage_list_by_location.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageListByLocation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SubscriptionUsageListByLocation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/synapse_link_workspace_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/synapse_link_workspace_list_by_database.py index ebd926c67fea..39f4f973ec6b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/synapse_link_workspace_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/synapse_link_workspace_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/SynapseLinkWorkspaceListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SynapseLinkWorkspaceListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_create.py index c692cb3514cc..6da3fc4aca79 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_create.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_delete.py index 48d0aa6e3f29..6c17173d2ca6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_generate_key.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_generate_key.py index 61cb966f8145..d01eacb0e0b7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_generate_key.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_generate_key.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGenerateKey.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentGenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get.py index 5bd6bd1d6235..23bceeac52cb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get_linked_databases.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get_linked_databases.py index ba594c4ba858..f8e791ff12e3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get_linked_databases.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_get_linked_databases.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGetLinkedDatabases.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentGetLinkedDatabases.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_list_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_list_by_server.py index be7e747242d2..ede6789aeb33 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_list_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_list_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentListByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentListByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_update.py index e03de9ff045b..fbd034d665b0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_agent_update.py @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncAgentUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_cancel_sync.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_cancel_sync.py index a01d50f40338..404261239456 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_cancel_sync.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_cancel_sync.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCancelSync.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupCancelSync.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create.py index ccd18c4c80da..45be6fa620b6 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_create.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_delete.py index 3697e093e721..642bae5bc726 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get.py index 4c59d42489cf..503bfc0dbbe5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_hub_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_hub_schema.py index 27e0f17ab4d6..60b7842189fc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_hub_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_hub_schema.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetHubSchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupGetHubSchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_log.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_log.py index c0b606ab4719..104497db8807 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_log.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_log.py @@ -42,6 +42,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetLog.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupGetLog.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_sync_database_id.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_sync_database_id.py index b85cbcad4cb9..73ffe28436f5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_sync_database_id.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_get_sync_database_id.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetSyncDatabaseId.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupGetSyncDatabaseId.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_list_by_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_list_by_database.py index 4731abac2c5a..c7d55fa1fe68 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_list_by_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_list_by_database.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupListByDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch.py index a13611ffcb3b..7ce598a23d7e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_patch.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupPatch.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupPatch.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_refresh_hub_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_refresh_hub_schema.py index 5def80c744c0..e08b41795f0a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_refresh_hub_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_refresh_hub_schema.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupRefreshHubSchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupRefreshHubSchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_trigger_sync.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_trigger_sync.py index 9d7f5f0fa7f7..bc843f3d8a78 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_trigger_sync.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_trigger_sync.py @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupTriggerSync.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupTriggerSync.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_update.py index b13ac1f83501..aa5120007801 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_group_update.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncGroupUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create.py index b3c6fba195e1..c1be02f1db90 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_create.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberCreate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberCreate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_delete.py index 446300384fc3..65c6d33c251c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get.py index b7784d90af09..567e29bb2aa3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_schema.py index 2d46c3ac9038..d5368d490240 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_get_schema.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGetSchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberGetSchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_list_by_sync_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_list_by_sync_group.py index 4bce23f44ced..6598a7e0f819 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_list_by_sync_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_list_by_sync_group.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberListBySyncGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberListBySyncGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch.py index 1b05d3be040f..8e905279a332 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_patch.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberPatch.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberPatch.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_refresh_schema.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_refresh_schema.py index 17c9e1a4b6dd..6f0d3d013002 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_refresh_schema.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_refresh_schema.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberRefreshSchema.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberRefreshSchema.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_update.py index b287819ac62e..6c1393288549 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/sync_member_update.py @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/SyncMemberUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_get.py index 9e8902943254..b784c0f06a1b 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/TransparentDataEncryptionGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_list.py index 3e2275f884ea..b9a8a0b5648e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/TransparentDataEncryptionList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_update.py index 1fcc0d06ed56..227fb55ecd2e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/transparent_data_encryption_update.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/TransparentDataEncryptionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py index bd5b342c9b82..2b224da38f29 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py index e21b57e318cc..6211b1376faa 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py index 6367b898c94b..4e29e20c481c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateJobAgent.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateJobAgent.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py new file mode 100644 index 000000000000..47f284b1396b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent_with_identity.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python update_job_agent_with_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.job_agents.begin_update( + resource_group_name="group1", + server_name="server1", + job_agent_name="agent1", + parameters={ + "identity": { + "type": "UserAssigned", + "userAssignedIdentities": { + "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": {} + }, + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateJobAgentWithIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py index 83df76344806..e2dcb8b00ec3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateManagedShortTermRetentionPolicy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy_restorable_dropped.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy_restorable_dropped.py index 4cbae2fcb5a3..82c377726d25 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy_restorable_dropped.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_managed_short_term_retention_policy_restorable_dropped.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicyRestorableDropped.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateManagedShortTermRetentionPolicyRestorableDropped.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py index 663ec3b45548..4dc33b9efb48 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_short_term_retention_policy.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/UpdateShortTermRetentionPolicy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateShortTermRetentionPolicy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_virtual_cluster_dns_servers.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_virtual_cluster_dns_servers.py index 79c544683464..17708e196cd1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_virtual_cluster_dns_servers.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_virtual_cluster_dns_servers.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/UpdateVirtualClusterDnsServers.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpdateVirtualClusterDnsServers.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py b/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py index bc3ea7e8b9a7..8e698e892413 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpgradeDataWarehouse.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/UpgradeDataWarehouse.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py index d596b95fe655..9c5f121212a0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py @@ -35,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualClusterDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_get.py index d5c54b066706..a1aa783e8b32 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualClusterGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list.py index c24b09cbcbbd..8454c06b7808 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualClusterList.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list_by_resource_group.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list_by_resource_group.py index cce68103817f..8f8482cd8952 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list_by_resource_group.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_list_by_resource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterListByResourceGroup.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualClusterListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_update.py index f5074ed941b6..d25afaabc602 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_update.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualClusterUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_create_or_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_create_or_update.py index 99d9350b33d8..1c8d853d0bbb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_create_or_update.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_delete.py index be6cdf51fe8b..236dd9b0e9d8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesDelete.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualNetworkRulesDelete.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_get.py index edbb19a9740e..22c5be8e2e4a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualNetworkRulesGet.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_list.py index cd4e8ac971c6..00e6e2271c0e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_network_rules_list.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/VirtualNetworkRulesList.json if __name__ == "__main__": main()