From 334a353b5610b4d0879a98c7d52b21d876dff3bc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 7 Sep 2023 16:21:57 +0000 Subject: [PATCH] CodeGen from PR 25467 in Azure/azure-rest-api-specs Merge 7964daf337071cd0c16fbeb26b97096c630c1420 into c1d7ef4e6ff16ff97f24b1497c82de0b665310c5 --- sdk/sql/azure-mgmt-sql/_meta.json | 4 +- .../azure/mgmt/sql/_configuration.py | 6 + .../azure/mgmt/sql/_sql_management_client.py | 733 +++-- .../azure-mgmt-sql/azure/mgmt/sql/_version.py | 2 +- .../azure/mgmt/sql/aio/_configuration.py | 6 + .../mgmt/sql/aio/_sql_management_client.py | 765 +++-- .../azure/mgmt/sql/aio/operations/__init__.py | 318 +- ...hort_term_retention_policies_operations.py | 192 +- .../operations/_capabilities_operations.py | 2 +- .../_data_masking_policies_operations.py | 195 +- .../_data_masking_rules_operations.py | 227 +- ...ta_warehouse_user_activities_operations.py | 170 +- ...d_threat_protection_settings_operations.py | 20 +- .../_database_advisors_operations.py | 6 +- .../_database_automatic_tuning_operations.py | 4 +- ...abase_blob_auditing_policies_operations.py | 20 +- .../_database_columns_operations.py | 33 +- ...tabase_encryption_protectors_operations.py | 8 +- .../_database_extensions_operations.py | 197 +- .../_database_operations_operations.py | 148 +- ...database_recommended_actions_operations.py | 6 +- .../_database_schemas_operations.py | 18 +- ...base_security_alert_policies_operations.py | 196 +- ...ability_assessment_baselines_operations.py | 20 +- ...lity_assessment_execute_scan_operations.py | 4 +- ...ty_assessment_rule_baselines_operations.py | 22 +- ...ility_assessment_scan_result_operations.py | 18 +- ...lnerability_assessment_scans_operations.py | 18 +- ...ability_assessments_settings_operations.py | 18 +- .../operations/_database_tables_operations.py | 18 +- .../operations/_database_usages_operations.py | 16 +- ...ty_assessment_rule_baselines_operations.py | 6 +- ...lnerability_assessment_scans_operations.py | 296 +- ...se_vulnerability_assessments_operations.py | 190 +- .../aio/operations/_databases_operations.py | 258 +- .../operations/_deleted_servers_operations.py | 157 +- ...tributed_availability_groups_operations.py | 283 +- .../_elastic_pool_activities_operations.py | 136 - ...tic_pool_database_activities_operations.py | 137 - .../_elastic_pool_operations_operations.py | 148 +- .../operations/_elastic_pools_operations.py | 206 +- .../_encryption_protectors_operations.py | 26 +- .../_endpoint_certificates_operations.py | 18 +- ...abase_blob_auditing_policies_operations.py | 20 +- ...erver_blob_auditing_policies_operations.py | 22 +- .../operations/_failover_groups_operations.py | 42 +- .../operations/_firewall_rules_operations.py | 440 +-- .../_geo_backup_policies_operations.py | 348 +-- .../_instance_failover_groups_operations.py | 34 +- .../operations/_instance_pools_operations.py | 325 ++- .../_ipv6_firewall_rules_operations.py | 22 +- .../aio/operations/_job_agents_operations.py | 30 +- .../operations/_job_credentials_operations.py | 22 +- .../operations/_job_executions_operations.py | 433 +-- .../_job_step_executions_operations.py | 18 +- .../aio/operations/_job_steps_operations.py | 389 +-- .../_job_target_executions_operations.py | 237 +- .../_job_target_groups_operations.py | 22 +- .../operations/_job_versions_operations.py | 18 +- .../sql/aio/operations/_jobs_operations.py | 22 +- .../_ledger_digest_uploads_operations.py | 188 +- ..._long_term_retention_backups_operations.py | 1709 +++++------ ...ion_managed_instance_backups_operations.py | 543 ++-- ...long_term_retention_policies_operations.py | 192 +- .../_maintenance_window_options_operations.py | 2 +- .../_maintenance_windows_operations.py | 4 +- ...hort_term_retention_policies_operations.py | 192 +- ...d_threat_protection_settings_operations.py | 20 +- .../_managed_database_columns_operations.py | 33 +- ...ged_database_move_operations_operations.py | 18 +- .../_managed_database_queries_operations.py | 18 +- ...commended_sensitivity_labels_operations.py | 2 +- ...ged_database_restore_details_operations.py | 2 +- .../_managed_database_schemas_operations.py | 18 +- ...base_security_alert_policies_operations.py | 196 +- ...ged_database_security_events_operations.py | 16 +- ..._database_sensitivity_labels_operations.py | 743 +++-- .../_managed_database_tables_operations.py | 18 +- ..._transparent_data_encryption_operations.py | 188 +- ...ty_assessment_rule_baselines_operations.py | 6 +- ...lnerability_assessment_scans_operations.py | 418 +-- ...se_vulnerability_assessments_operations.py | 190 +- .../_managed_databases_operations.py | 61 +- ...aged_instance_administrators_operations.py | 26 +- ...d_threat_protection_settings_operations.py | 22 +- ...zure_ad_only_authentications_operations.py | 186 +- .../_managed_instance_dtcs_operations.py | 22 +- ...stance_encryption_protectors_operations.py | 274 +- .../_managed_instance_keys_operations.py | 26 +- ...long_term_retention_policies_operations.py | 286 +- ..._managed_instance_operations_operations.py | 20 +- ...private_endpoint_connections_operations.py | 186 +- ...tance_private_link_resources_operations.py | 18 +- ...ed_instance_tde_certificates_operations.py | 4 +- ...ce_vulnerability_assessments_operations.py | 184 +- .../_managed_instances_operations.py | 299 +- ...anaged_ledger_digest_uploads_operations.py | 26 +- ...hort_term_retention_policies_operations.py | 192 +- .../_managed_server_dns_aliases_operations.py | 30 +- ...rver_security_alert_policies_operations.py | 204 +- ...ity_perimeter_configurations_operations.py | 349 +++ .../mgmt/sql/aio/operations/_operations.py | 16 +- .../_outbound_firewall_rules_operations.py | 303 +- ...private_endpoint_connections_operations.py | 26 +- .../_private_link_resources_operations.py | 18 +- ...commended_sensitivity_labels_operations.py | 2 +- .../_recoverable_databases_operations.py | 18 +- ...ecoverable_managed_databases_operations.py | 18 +- .../_replication_links_operations.py | 45 +- ...restorable_dropped_databases_operations.py | 18 +- ...le_dropped_managed_databases_operations.py | 18 +- .../operations/_restore_points_operations.py | 24 +- .../_sensitivity_labels_operations.py | 481 ++-- ...d_threat_protection_settings_operations.py | 22 +- .../operations/_server_advisors_operations.py | 6 +- .../_server_automatic_tuning_operations.py | 4 +- ...rver_azure_ad_administrators_operations.py | 186 +- ...zure_ad_only_authentications_operations.py | 186 +- ...erver_blob_auditing_policies_operations.py | 22 +- .../_server_communication_links_operations.py | 507 ---- ...server_configuration_options_operations.py | 22 +- .../_server_connection_policies_operations.py | 180 +- ...erver_dev_ops_audit_settings_operations.py | 22 +- .../_server_dns_aliases_operations.py | 186 +- .../aio/operations/_server_keys_operations.py | 26 +- .../_server_operations_operations.py | 16 +- ...rver_security_alert_policies_operations.py | 204 +- .../_server_trust_certificates_operations.py | 26 +- .../_server_trust_groups_operations.py | 197 +- .../operations/_server_usages_operations.py | 20 +- ...er_vulnerability_assessments_operations.py | 182 +- .../sql/aio/operations/_servers_operations.py | 55 +- .../_service_objectives_operations.py | 200 -- .../aio/operations/_sql_agent_operations.py | 4 +- ...rability_assessment_baseline_operations.py | 18 +- ...ability_assessment_baselines_operations.py | 2 +- ...lity_assessment_execute_scan_operations.py | 4 +- ...ity_assessment_rule_baseline_operations.py | 20 +- ...ty_assessment_rule_baselines_operations.py | 2 +- ...ility_assessment_scan_result_operations.py | 18 +- ...lnerability_assessment_scans_operations.py | 18 +- ...ql_vulnerability_assessments_operations.py | 2 +- ...ability_assessments_settings_operations.py | 20 +- ...p_managed_instance_schedules_operations.py | 22 +- .../_subscription_usages_operations.py | 18 +- .../_synapse_link_workspaces_operations.py | 16 +- .../aio/operations/_sync_agents_operations.py | 199 +- .../aio/operations/_sync_groups_operations.py | 965 ++++--- .../operations/_sync_members_operations.py | 409 +-- .../_tde_certificates_operations.py | 4 +- .../aio/operations/_time_zones_operations.py | 18 +- ...transparent_data_encryptions_operations.py | 22 +- .../sql/aio/operations/_usages_operations.py | 16 +- .../_virtual_clusters_operations.py | 45 +- .../_virtual_network_rules_operations.py | 182 +- .../_workload_classifiers_operations.py | 196 +- .../operations/_workload_groups_operations.py | 188 +- .../azure/mgmt/sql/models/__init__.py | 124 +- .../azure/mgmt/sql/models/_models_py3.py | 2565 ++++++++++------- .../models/_sql_management_client_enums.py | 253 +- .../azure/mgmt/sql/operations/__init__.py | 318 +- ...hort_term_retention_policies_operations.py | 238 +- .../operations/_capabilities_operations.py | 4 +- .../_data_masking_policies_operations.py | 233 +- .../_data_masking_rules_operations.py | 267 +- ...ta_warehouse_user_activities_operations.py | 202 +- ...d_threat_protection_settings_operations.py | 26 +- .../_database_advisors_operations.py | 12 +- .../_database_automatic_tuning_operations.py | 8 +- ...abase_blob_auditing_policies_operations.py | 26 +- .../_database_columns_operations.py | 39 +- ...tabase_encryption_protectors_operations.py | 12 +- .../_database_extensions_operations.py | 253 +- .../_database_operations_operations.py | 192 +- ...database_recommended_actions_operations.py | 12 +- .../_database_schemas_operations.py | 22 +- ...base_security_alert_policies_operations.py | 236 +- ...ability_assessment_baselines_operations.py | 26 +- ...lity_assessment_execute_scan_operations.py | 6 +- ...ty_assessment_rule_baselines_operations.py | 30 +- ...ility_assessment_scan_result_operations.py | 22 +- ...lnerability_assessment_scans_operations.py | 22 +- ...ability_assessments_settings_operations.py | 22 +- .../operations/_database_tables_operations.py | 22 +- .../operations/_database_usages_operations.py | 18 +- ...ty_assessment_rule_baselines_operations.py | 12 +- ...lnerability_assessment_scans_operations.py | 342 +-- ...se_vulnerability_assessments_operations.py | 252 +- .../sql/operations/_databases_operations.py | 321 +-- .../operations/_deleted_servers_operations.py | 175 +- ...tributed_availability_groups_operations.py | 333 ++- .../_elastic_pool_activities_operations.py | 171 -- ...tic_pool_database_activities_operations.py | 171 -- .../_elastic_pool_operations_operations.py | 192 +- .../operations/_elastic_pools_operations.py | 287 +- .../_encryption_protectors_operations.py | 34 +- .../_endpoint_certificates_operations.py | 22 +- ...abase_blob_auditing_policies_operations.py | 26 +- ...erver_blob_auditing_policies_operations.py | 28 +- .../operations/_failover_groups_operations.py | 58 +- .../operations/_firewall_rules_operations.py | 502 ++-- .../_geo_backup_policies_operations.py | 392 +-- .../_instance_failover_groups_operations.py | 46 +- .../operations/_instance_pools_operations.py | 405 +-- .../_ipv6_firewall_rules_operations.py | 30 +- .../sql/operations/_job_agents_operations.py | 40 +- .../operations/_job_credentials_operations.py | 30 +- .../operations/_job_executions_operations.py | 553 ++-- .../_job_step_executions_operations.py | 22 +- .../sql/operations/_job_steps_operations.py | 475 +-- .../_job_target_executions_operations.py | 305 +- .../_job_target_groups_operations.py | 30 +- .../operations/_job_versions_operations.py | 22 +- .../mgmt/sql/operations/_jobs_operations.py | 30 +- .../_ledger_digest_uploads_operations.py | 232 +- ..._long_term_retention_backups_operations.py | 2149 +++++++------- ...ion_managed_instance_backups_operations.py | 739 ++--- ...long_term_retention_policies_operations.py | 234 +- .../_maintenance_window_options_operations.py | 4 +- .../_maintenance_windows_operations.py | 8 +- ...hort_term_retention_policies_operations.py | 240 +- ...d_threat_protection_settings_operations.py | 26 +- .../_managed_database_columns_operations.py | 39 +- ...ged_database_move_operations_operations.py | 22 +- .../_managed_database_queries_operations.py | 22 +- ...commended_sensitivity_labels_operations.py | 4 +- ...ged_database_restore_details_operations.py | 4 +- .../_managed_database_schemas_operations.py | 22 +- ...base_security_alert_policies_operations.py | 236 +- ...ged_database_security_events_operations.py | 18 +- ..._database_sensitivity_labels_operations.py | 1014 ++++--- .../_managed_database_tables_operations.py | 22 +- ..._transparent_data_encryption_operations.py | 228 +- ...ty_assessment_rule_baselines_operations.py | 12 +- ...lnerability_assessment_scans_operations.py | 464 +-- ...se_vulnerability_assessments_operations.py | 252 +- .../_managed_databases_operations.py | 81 +- ...aged_instance_administrators_operations.py | 34 +- ...d_threat_protection_settings_operations.py | 28 +- ...zure_ad_only_authentications_operations.py | 244 +- .../_managed_instance_dtcs_operations.py | 28 +- ...stance_encryption_protectors_operations.py | 334 +-- .../_managed_instance_keys_operations.py | 34 +- ...long_term_retention_policies_operations.py | 335 ++- ..._managed_instance_operations_operations.py | 26 +- ...private_endpoint_connections_operations.py | 248 +- ...tance_private_link_resources_operations.py | 22 +- ...ed_instance_tde_certificates_operations.py | 6 +- ...ce_vulnerability_assessments_operations.py | 246 +- .../_managed_instances_operations.py | 373 ++- ...anaged_ledger_digest_uploads_operations.py | 34 +- ...hort_term_retention_policies_operations.py | 228 +- .../_managed_server_dns_aliases_operations.py | 40 +- ...rver_security_alert_policies_operations.py | 244 +- ...ty_perimeter_configurations_operations.py} | 458 +-- .../azure/mgmt/sql/operations/_operations.py | 18 +- .../_outbound_firewall_rules_operations.py | 350 +-- ...private_endpoint_connections_operations.py | 34 +- .../_private_link_resources_operations.py | 22 +- ...commended_sensitivity_labels_operations.py | 4 +- .../_recoverable_databases_operations.py | 22 +- ...ecoverable_managed_databases_operations.py | 22 +- .../_replication_links_operations.py | 57 +- ...restorable_dropped_databases_operations.py | 22 +- ...le_dropped_managed_databases_operations.py | 22 +- .../operations/_restore_points_operations.py | 32 +- .../_sensitivity_labels_operations.py | 682 +++-- ...d_threat_protection_settings_operations.py | 28 +- .../operations/_server_advisors_operations.py | 12 +- .../_server_automatic_tuning_operations.py | 8 +- ...rver_azure_ad_administrators_operations.py | 242 +- ...zure_ad_only_authentications_operations.py | 242 +- ...erver_blob_auditing_policies_operations.py | 28 +- ...server_configuration_options_operations.py | 28 +- .../_server_connection_policies_operations.py | 220 +- ...erver_dev_ops_audit_settings_operations.py | 28 +- .../_server_dns_aliases_operations.py | 232 +- .../sql/operations/_server_keys_operations.py | 34 +- .../_server_operations_operations.py | 18 +- ...rver_security_alert_policies_operations.py | 244 +- .../_server_trust_certificates_operations.py | 34 +- .../_server_trust_groups_operations.py | 249 +- .../operations/_server_usages_operations.py | 24 +- ...er_vulnerability_assessments_operations.py | 242 +- .../sql/operations/_servers_operations.py | 73 +- .../_service_objectives_operations.py | 265 -- .../sql/operations/_sql_agent_operations.py | 8 +- ...rability_assessment_baseline_operations.py | 22 +- ...ability_assessment_baselines_operations.py | 4 +- ...lity_assessment_execute_scan_operations.py | 6 +- ...ity_assessment_rule_baseline_operations.py | 26 +- ...ty_assessment_rule_baselines_operations.py | 4 +- ...ility_assessment_scan_result_operations.py | 22 +- ...lnerability_assessment_scans_operations.py | 22 +- ...ql_vulnerability_assessments_operations.py | 4 +- ...ability_assessments_settings_operations.py | 26 +- ...p_managed_instance_schedules_operations.py | 30 +- .../_subscription_usages_operations.py | 22 +- .../_synapse_link_workspaces_operations.py | 18 +- .../sql/operations/_sync_agents_operations.py | 253 +- .../sql/operations/_sync_groups_operations.py | 1457 +++++----- .../operations/_sync_members_operations.py | 495 ++-- .../_tde_certificates_operations.py | 6 +- .../sql/operations/_time_zones_operations.py | 22 +- ...transparent_data_encryptions_operations.py | 28 +- .../mgmt/sql/operations/_usages_operations.py | 18 +- .../_virtual_clusters_operations.py | 57 +- .../_virtual_network_rules_operations.py | 232 +- .../_workload_classifiers_operations.py | 244 +- .../operations/_workload_groups_operations.py | 248 +- .../administrator_create_or_update.py | 2 +- .../generated_samples/administrator_delete.py | 2 +- .../generated_samples/administrator_get.py | 2 +- .../generated_samples/administrator_list.py | 2 +- .../azure_ad_only_auth_create_or_update.py | 2 +- .../azure_ad_only_auth_delete.py | 2 +- .../azure_ad_only_auth_get.py | 2 +- .../azure_ad_only_auth_list.py | 2 +- .../cancel_database_operation.py | 2 +- .../cancel_elastic_pool_operation.py | 2 +- .../generated_samples/cancel_job_execution.py | 2 +- .../cancel_managed_instance_operation.py | 2 +- ...name_availability_server_already_exists.py | 2 +- ...heck_name_availability_server_available.py | 2 +- .../check_name_availability_server_invalid.py | 2 +- .../column_sensitivity_label_create_max.py | 3 +- .../column_sensitivity_label_delete.py | 2 +- .../column_sensitivity_label_get.py | 2 +- .../columns_list_by_database_max.py | 2 +- .../columns_list_by_database_min.py | 2 +- ...ate_elastic_pool_with_availability_zone.py | 2 +- .../generated_samples/create_job_execution.py | 2 +- .../create_managed_database_ledger.py | 2 +- .../create_or_update_database_extensions.py | 2 +- .../create_or_update_instance_pool_max.py | 2 +- .../create_or_update_instance_pool_min.py | 2 +- .../create_or_update_job_agent.py | 2 +- .../create_or_update_job_credential.py | 2 +- .../create_or_update_job_execution.py | 2 +- .../create_or_update_job_max.py | 2 +- .../create_or_update_job_step_max.py | 2 +- .../create_or_update_job_step_min.py | 2 +- .../create_or_update_job_target_group_max.py | 2 +- .../create_or_update_job_target_group_min.py | 2 +- .../create_or_update_maintenance_windows.py | 2 +- ...reate_or_update_workload_classifier_max.py | 2 +- ...reate_or_update_workload_classifier_min.py | 2 +- .../create_or_update_workload_group_max.py | 2 +- .../create_or_update_workload_group_min.py | 2 +- ...ata_masking_policy_create_or_update_max.py | 3 +- ...ata_masking_policy_create_or_update_min.py | 3 +- .../data_masking_policy_get.py | 3 +- ...sking_rule_create_or_update_default_max.py | 3 +- ...sking_rule_create_or_update_default_min.py | 3 +- ...ta_masking_rule_create_or_update_number.py | 3 +- ...data_masking_rule_create_or_update_text.py | 3 +- ... => data_masking_rule_list_by_database.py} | 5 +- .../data_warehouse_restore_points_get.py | 2 +- ...rehouse_restore_points_list_by_database.py | 2 +- ...d_threat_protection_settings_create_max.py | 2 +- ...d_threat_protection_settings_create_min.py | 2 +- ...advanced_threat_protection_settings_get.py | 2 +- ...at_protection_settings_list_by_database.py | 2 +- .../generated_samples/database_advisor_get.py | 2 +- .../database_advisor_list.py | 2 +- .../database_advisor_update.py | 2 +- .../database_auditing_settings_list.py | 2 +- .../database_automatic_tuning_get.py | 2 +- .../database_automatic_tuning_update_max.py | 2 +- .../database_automatic_tuning_update_min.py | 2 +- ...abase_azure_monitor_auditing_create_min.py | 2 +- .../database_blob_auditing_create_max.py | 2 +- .../database_blob_auditing_create_min.py | 2 +- .../database_blob_auditing_get.py | 2 +- .../generated_samples/database_column_get.py | 2 +- .../database_column_list_by_table.py | 2 +- ...atabase_encryption_protector_revalidate.py | 2 +- .../database_encryption_protector_revert.py | 2 +- ...atabase_extended_auditing_settings_list.py | 2 +- .../database_recommended_action_get.py | 2 +- .../database_recommended_action_list.py | 2 +- ...database_recommended_action_list_expand.py | 2 +- .../database_recommended_action_update.py | 2 +- .../database_restore_points_delete.py | 2 +- .../database_restore_points_get.py | 2 +- ...atabase_restore_points_list_by_database.py | 2 +- .../database_restore_points_post.py | 2 +- .../generated_samples/database_schema_get.py | 2 +- .../database_schema_list_by_database.py | 2 +- .../database_security_alert_create_max.py | 4 +- .../database_security_alert_create_min.py | 4 +- .../database_security_alert_get.py | 4 +- ...atabase_security_alert_list_by_database.py | 2 +- ...l_vulnerability_assessment_baseline_add.py | 2 +- ...rability_assessment_baseline_add_latest.py | 2 +- ...l_vulnerability_assessment_baseline_get.py | 2 +- ...ne_list_by_sql_vulnerability_assessment.py | 2 +- ...tabase_sql_vulnerability_assessment_get.py | 2 +- ...lnerability_assessment_list_by_database.py | 2 +- ...erability_assessment_list_scans_results.py | 2 +- ...ability_assessment_rule_baseline_create.py | 2 +- ...ability_assessment_rule_baseline_delete.py | 2 +- ...nerability_assessment_rule_baseline_get.py | 2 +- ...sessment_rule_baseline_list_by_baseline.py | 2 +- ...abase_sql_vulnerability_assessment_scan.py | 2 +- ...ssessment_scan_records_list_by_database.py | 2 +- ..._vulnerability_assessment_scans_execute.py | 2 +- ..._vulnerability_assessment_scans_results.py | 2 +- .../generated_samples/database_table_get.py | 2 +- .../database_table_list_by_schema.py | 2 +- ...assessment_create_container_sas_key_min.py | 2 +- ...ase_vulnerability_assessment_create_max.py | 2 +- ...ssessment_create_storage_access_key_min.py | 2 +- ...atabase_vulnerability_assessment_delete.py | 2 +- .../database_vulnerability_assessment_get.py | 2 +- ...lnerability_assessment_list_by_database.py | 2 +- ...ability_assessment_rule_baseline_create.py | 2 +- ...ability_assessment_rule_baseline_delete.py | 2 +- ...nerability_assessment_rule_baseline_get.py | 2 +- ...se_vulnerability_assessment_scan_export.py | 2 +- ...lnerability_assessment_scan_records_get.py | 2 +- ...ssessment_scan_records_list_by_database.py | 2 +- ..._vulnerability_assessment_scans_execute.py | 2 +- .../generated_samples/delete_instance_pool.py | 2 +- .../generated_samples/delete_job.py | 2 +- .../generated_samples/delete_job_agent.py | 2 +- .../delete_job_credential.py | 2 +- .../generated_samples/delete_job_step.py | 2 +- .../delete_job_target_group.py | 2 +- .../delete_workload_classifier.py | 2 +- .../delete_workload_group.py | 2 +- .../generated_samples/deleted_server_get.py | 2 +- .../generated_samples/deleted_server_list.py | 2 +- .../deleted_server_list_by_subscription.py | 2 +- .../deleted_server_recover.py | 2 +- .../distributed_availability_groups_create.py | 2 +- .../distributed_availability_groups_delete.py | 4 +- .../distributed_availability_groups_get.py | 4 +- ...ed_availability_groups_list_by_instance.py | 2 +- ...stributed_availability_groups_set_role.py} | 18 +- .../distributed_availability_groups_update.py | 2 +- .../elastic_pool_create_or_update_max.py | 2 +- .../elastic_pool_create_or_update_min.py | 2 +- ...or_update_set_maintenance_configuration.py | 2 +- ...ate_with_default_preferred_enclave_type.py | 2 +- ..._create_with_vbs_preferred_enclave_type.py | 2 +- .../elastic_pool_database_activity_list.py | 43 - .../generated_samples/elastic_pool_delete.py | 2 +- .../generated_samples/elastic_pool_get.py | 2 +- ...ic_pool_get_with_preferred_enclave_type.py | 2 +- .../elastic_pool_list_by_server.py | 2 +- ...update_assign_maintenance_configuration.py | 2 +- .../elastic_pool_update_max.py | 2 +- ..._update_reset_maintenance_configuration.py | 2 +- ...ate_with_default_preferred_enclave_type.py | 2 +- ..._update_with_vbs_preferred_enclave_type.py | 2 +- ...on_protector_create_or_update_key_vault.py | 2 +- ...tector_create_or_update_service_managed.py | 2 +- .../encryption_protector_get.py | 2 +- .../encryption_protector_list.py | 2 +- .../encryption_protector_revalidate.py | 2 +- .../endpoint_certificates_get.py | 2 +- .../endpoint_certificates_list_by_instance.py | 2 +- ...port_database_using_database_extensions.py | 54 + ...abase_azure_monitor_auditing_create_min.py | 2 +- ...ended_database_blob_auditing_create_max.py | 2 +- ...ended_database_blob_auditing_create_min.py | 2 +- .../extended_database_blob_auditing_get.py | 2 +- ...xtended_server_blob_auditing_create_max.py | 2 +- ...xtended_server_blob_auditing_create_min.py | 2 +- .../extended_server_blob_auditing_get.py | 2 +- .../failover_elastic_pool.py | 2 +- .../failover_group_create_or_update.py | 2 +- .../failover_group_delete.py | 2 +- .../failover_group_failover.py | 2 +- ...er_group_force_failover_allow_data_loss.py | 2 +- .../generated_samples/failover_group_get.py | 6 +- .../generated_samples/failover_group_list.py | 2 +- ...roup_try_planned_before_forced_failover.py | 2 +- .../failover_group_update.py | 2 +- .../failover_managed_instance.py | 2 +- .../generated_samples/firewall_rule_create.py | 2 +- .../generated_samples/firewall_rule_delete.py | 2 +- .../generated_samples/firewall_rule_get.py | 2 +- .../generated_samples/firewall_rule_list.py | 2 +- .../firewall_rule_replace.py | 2 +- .../generated_samples/firewall_rule_update.py | 2 +- .../geo_backup_policies_create_or_update.py | 2 +- .../geo_backup_policies_get.py | 2 +- .../geo_backup_policies_list.py | 4 +- .../get_data_warehouse_user_activities.py | 2 +- .../get_database_extensions.py | 2 +- .../generated_samples/get_database_usages.py | 2 +- ...get_elastic_pool_with_availability_zone.py | 2 +- .../generated_samples/get_instance_pool.py | 2 +- .../generated_samples/get_job.py | 2 +- .../generated_samples/get_job_agent.py | 2 +- .../generated_samples/get_job_credential.py | 2 +- .../generated_samples/get_job_execution.py | 2 +- .../get_job_execution_step.py | 2 +- .../get_job_execution_target.py | 2 +- .../generated_samples/get_job_step_by_job.py | 2 +- .../get_job_step_by_version.py | 2 +- .../generated_samples/get_job_target_group.py | 2 +- .../generated_samples/get_job_version.py | 2 +- ...ist_managed_short_term_retention_policy.py | 2 +- ...erm_retention_policy_restorable_dropped.py | 2 +- .../get_maintenance_window_options.py | 2 +- .../get_maintenance_windows.py | 2 +- .../get_managed_instance_operation.py | 2 +- ...get_managed_short_term_retention_policy.py | 2 +- ...erm_retention_policy_restorable_dropped.py | 2 +- .../get_recoverable_managed_database.py | 2 +- .../get_restorable_dropped_database.py | 2 +- ...ropped_database_with_expand_equals_keys.py | 2 +- ...get_restorable_dropped_managed_database.py | 2 +- .../get_short_term_retention_policy.py | 2 +- .../get_workload_classifier.py | 2 +- .../get_workload_classifier_list.py | 2 +- .../generated_samples/get_workload_group.py | 2 +- .../get_workload_group_list.py | 2 +- ...ate_set_high_availability_replica_count.py | 2 +- .../hyperscale_elastic_pool_get.py | 2 +- ...ate_set_high_availability_replica_count.py | 2 +- ...port_database_using_database_extensions.py | 54 + .../generated_samples/import_new_database.py | 2 +- ...ort_new_database_with_network_isolation.py | 2 +- ...naged_database_list_by_managed_instance.py | 2 +- ...nstance_failover_group_create_or_update.py | 2 +- .../instance_failover_group_delete.py | 2 +- .../instance_failover_group_failover.py | 2 +- ...er_group_force_failover_allow_data_loss.py | 2 +- .../instance_failover_group_get.py | 2 +- .../instance_failover_group_list.py | 2 +- .../ipv6_firewall_rule_create.py | 2 +- .../ipv6_firewall_rule_delete.py | 2 +- .../ipv6_firewall_rule_get.py | 2 +- .../ipv6_firewall_rule_list.py | 2 +- .../ipv6_firewall_rule_update.py | 2 +- .../ledger_digest_uploads_disable.py | 2 +- .../ledger_digest_uploads_enable.py | 2 +- .../ledger_digest_uploads_get.py | 2 +- .../ledger_digest_uploads_list.py | 2 +- .../list_data_warehouse_user_activities.py | 2 +- .../list_database_extensions.py | 2 +- .../list_database_operations.py | 6 +- .../list_elastic_pool_operations.py | 2 +- .../list_instance_pool_usage.py | 2 +- .../list_instance_pool_usage_expanded.py | 2 +- .../list_instance_pools_by_resource_group.py | 2 +- .../list_instance_pools_by_subscription_id.py | 2 +- .../list_job_agents_by_server.py | 2 +- .../list_job_credentials_by_agent.py | 2 +- .../list_job_execution_steps.py | 2 +- ...list_job_execution_targets_by_execution.py | 2 +- .../list_job_execution_targets_by_step.py | 2 +- .../list_job_executions_by_agent.py | 2 +- ...ist_job_executions_by_agent_with_filter.py | 2 +- .../list_job_executions_by_job.py | 2 +- .../list_job_steps_by_job.py | 2 +- .../list_job_steps_by_version.py | 2 +- .../list_job_target_groups.py | 2 +- .../generated_samples/list_job_versions.py | 2 +- .../generated_samples/list_jobs_by_agent.py | 2 +- .../list_managed_instance_operations.py | 2 +- ...e_objective_list.py => list_operations.py} | 11 +- ...etwork_dependencies_by_managed_instance.py | 2 +- ...recoverable_managed_databases_by_server.py | 2 +- ..._restorable_dropped_databases_by_server.py | 2 +- .../list_server_operations.py | 2 +- ...ort_term_retention_policies_by_database.py | 2 +- .../location_capability_list_by_location.py | 2 +- .../long_term_retention_backup_copy.py | 2 +- .../long_term_retention_backup_delete.py | 2 +- .../long_term_retention_backup_get.py | 2 +- ..._term_retention_backup_list_by_database.py | 2 +- ..._term_retention_backup_list_by_location.py | 2 +- ...ng_term_retention_backup_list_by_server.py | 2 +- .../long_term_retention_backup_update.py | 2 +- ..._term_retention_policy_create_or_update.py | 3 +- .../long_term_retention_policy_get.py | 2 +- ..._term_retention_policy_list_by_database.py | 2 +- .../managed_columns_list_by_database_max.py | 2 +- .../managed_columns_list_by_database_min.py | 2 +- ...d_threat_protection_settings_create_max.py | 2 +- ...d_threat_protection_settings_create_min.py | 2 +- ...advanced_threat_protection_settings_get.py | 2 +- ...at_protection_settings_list_by_database.py | 2 +- .../managed_database_cancel_move.py | 2 +- .../managed_database_column_get.py | 2 +- .../managed_database_column_list_by_table.py | 2 +- ...atabase_column_sensitivity_label_create.py | 3 +- ...atabase_column_sensitivity_label_delete.py | 2 +- ...d_database_column_sensitivity_label_get.py | 2 +- ...aged_database_complete_external_restore.py | 2 +- .../managed_database_complete_move.py | 2 +- ...ross_subscription_point_in_time_restore.py | 2 +- .../managed_database_create_max.py | 2 +- .../managed_database_create_min.py | 2 +- ...d_database_create_point_in_time_restore.py | 2 +- .../managed_database_create_recovery.py | 2 +- ...database_create_restore_external_backup.py | 2 +- ...estore_external_backup_managed_identity.py | 2 +- ...aged_database_create_restore_ltr_backup.py | 2 +- .../managed_database_delete.py | 2 +- .../generated_samples/managed_database_get.py | 2 +- ...naged_database_list_by_managed_instance.py | 2 +- ...aged_database_move_operation_result_get.py | 2 +- ...ged_database_move_operation_result_list.py | 2 +- ...e_operation_result_list_last_operations.py | 2 +- ...database_move_operation_result_list_max.py | 2 +- ...mended_column_sensitivity_label_disable.py | 2 +- ...mmended_column_sensitivity_label_enable.py | 2 +- .../managed_database_restore_details.py | 2 +- .../managed_database_schema_get.py | 2 +- ...anaged_database_schema_list_by_database.py | 2 +- ...aged_database_security_alert_create_max.py | 4 +- ...aged_database_security_alert_create_min.py | 4 +- .../managed_database_security_alert_get.py | 4 +- ...atabase_security_alert_list_by_database.py | 2 +- ...anaged_database_security_events_get_max.py | 2 +- ...anaged_database_security_events_get_min.py | 2 +- ...abase_sensitivity_labels_current_update.py | 2 +- ...se_sensitivity_labels_list_by_database.py} | 12 +- ...itivity_labels_list_by_database_current.py | 2 +- ...ity_labels_list_by_database_recommended.py | 2 +- ...e_sensitivity_labels_recommended_update.py | 2 +- .../managed_database_start_move_max.py | 2 +- .../managed_database_start_move_min.py | 2 +- .../managed_database_table_get.py | 2 +- .../managed_database_table_list_by_schema.py | 2 +- .../managed_database_update_max.py | 2 +- .../managed_database_update_min.py | 2 +- ...ase_vulnerability_assessment_create_max.py | 2 +- ...ase_vulnerability_assessment_create_min.py | 2 +- ...atabase_vulnerability_assessment_delete.py | 2 +- ...d_database_vulnerability_assessment_get.py | 2 +- ...lnerability_assessment_list_by_database.py | 2 +- ...ability_assessment_rule_baseline_create.py | 2 +- ...ability_assessment_rule_baseline_delete.py | 2 +- ...nerability_assessment_rule_baseline_get.py | 2 +- ...se_vulnerability_assessment_scan_export.py | 2 +- ...lnerability_assessment_scan_records_get.py | 2 +- ...ssessment_scan_records_list_by_database.py | 2 +- ..._vulnerability_assessment_scans_execute.py | 2 +- .../managed_instance_administrator_create.py | 2 +- .../managed_instance_administrator_delete.py | 2 +- .../managed_instance_administrator_get.py | 2 +- ...instance_administrator_list_by_instance.py | 2 +- .../managed_instance_administrator_update.py | 2 +- ...d_threat_protection_settings_create_max.py | 2 +- ...d_threat_protection_settings_create_min.py | 2 +- ...advanced_threat_protection_settings_get.py | 2 +- ...at_protection_settings_list_by_instance.py | 2 +- ...nce_azure_ad_only_auth_create_or_update.py | 2 +- ...aged_instance_azure_ad_only_auth_delete.py | 2 +- ...managed_instance_azure_ad_only_auth_get.py | 2 +- ...nce_azure_ad_only_auth_list_by_instance.py | 2 +- .../managed_instance_create_max.py | 3 +- .../managed_instance_create_min.py | 2 +- .../managed_instance_delete.py | 4 +- .../managed_instance_dtc_get.py | 2 +- .../managed_instance_dtc_list.py | 2 +- .../managed_instance_dtc_update_enable_dtc.py | 2 +- .../managed_instance_dtc_update_max.py | 2 +- ...on_protector_create_or_update_key_vault.py | 2 +- ...tector_create_or_update_service_managed.py | 2 +- ...naged_instance_encryption_protector_get.py | 2 +- ...aged_instance_encryption_protector_list.py | 2 +- ...nstance_encryption_protector_revalidate.py | 2 +- .../generated_samples/managed_instance_get.py | 4 +- ...e_get_with_expand_equals_administrators.py | 4 +- .../managed_instance_key_create_or_update.py | 2 +- .../managed_instance_key_delete.py | 2 +- .../managed_instance_key_get.py | 2 +- .../managed_instance_key_list.py | 2 +- .../managed_instance_list.py | 4 +- .../managed_instance_list_by_instance_pool.py | 4 +- ..._pool_with_expand_equals_administrators.py | 4 +- ...managed_instance_list_by_resource_group.py | 4 +- ...group_with_expand_equals_administrators.py | 4 +- ..._list_with_expand_equals_administrators.py | 4 +- ...tance_long_term_retention_backup_delete.py | 2 +- ...instance_long_term_retention_backup_get.py | 2 +- ..._term_retention_backup_list_by_database.py | 2 +- ..._term_retention_backup_list_by_instance.py | 2 +- ..._term_retention_backup_list_by_location.py | 2 +- ..._term_retention_policy_create_or_update.py | 2 +- ...ance_long_term_retention_policy_delete.py} | 15 +- ...instance_long_term_retention_policy_get.py | 2 +- ..._term_retention_policy_list_by_database.py | 2 +- ...ance_private_endpoint_connection_delete.py | 2 +- ...nstance_private_endpoint_connection_get.py | 2 +- ...stance_private_endpoint_connection_list.py | 2 +- ...ance_private_endpoint_connection_update.py | 2 +- ...ged_instance_private_link_resources_get.py | 2 +- ...ed_instance_private_link_resources_list.py | 2 +- .../managed_instance_query_get.py | 2 +- .../managed_instance_query_statistics_list.py | 2 +- ...aged_instance_query_statistics_list_max.py | 2 +- ...aged_instance_query_statistics_list_min.py | 2 +- ...stance_remove_maintenance_configuration.py | 6 +- .../managed_instance_tde_certificate.py | 2 +- .../managed_instance_time_zone_get.py | 2 +- ...ged_instance_time_zone_list_by_location.py | 2 +- .../managed_instance_top_queries_list.py | 2 +- .../managed_instance_top_queries_list_max.py | 2 +- .../managed_instance_top_queries_list_min.py | 2 +- .../managed_instance_update_max.py | 7 +- .../managed_instance_update_min.py | 4 +- ...assessment_create_container_sas_key_min.py | 2 +- ...nce_vulnerability_assessment_create_max.py | 2 +- ...ssessment_create_storage_access_key_min.py | 2 +- ...nstance_vulnerability_assessment_delete.py | 2 +- ...d_instance_vulnerability_assessment_get.py | 2 +- ...lnerability_assessment_list_by_instance.py | 2 +- .../managed_ledger_digest_uploads_disable.py | 2 +- .../managed_ledger_digest_uploads_enable.py | 2 +- .../managed_ledger_digest_uploads_get.py | 2 +- .../managed_ledger_digest_uploads_list.py | 2 +- .../managed_server_dns_alias_acquire.py | 2 +- .../managed_server_dns_alias_delete.py | 2 +- .../managed_server_dns_alias_get.py | 2 +- .../managed_server_dns_alias_list.py | 2 +- ...anaged_server_security_alert_create_max.py | 2 +- ...anaged_server_security_alert_create_min.py | 2 +- .../managed_server_security_alert_get.py | 2 +- ..._server_security_alert_list_by_instance.py | 2 +- ...managed_transparent_data_encryption_get.py | 2 +- ...anaged_transparent_data_encryption_list.py | 2 +- ...aged_transparent_data_encryption_update.py | 2 +- ...k_security_perimeter_configurations_get.py | 42 + ...erimeter_configurations_list_by_server.py} | 8 +- ...ity_perimeter_configurations_reconcile.py} | 11 +- ...et.py => outbound_firewall_rule_create.py} | 10 +- .../outbound_firewall_rule_delete.py | 2 +- .../outbound_firewall_rule_get.py | 2 +- .../outbound_firewall_rule_list.py | 2 +- .../generated_samples/patch_instance_pool.py | 2 +- .../private_endpoint_connection_delete.py | 2 +- .../private_endpoint_connection_get.py | 2 +- .../private_endpoint_connection_list.py | 2 +- .../private_endpoint_connection_update.py | 2 +- .../private_link_resources_get.py | 2 +- .../private_link_resources_list.py | 2 +- ...mended_column_sensitivity_label_disable.py | 2 +- ...mmended_column_sensitivity_label_enable.py | 2 +- .../recoverable_database_get.py | 2 +- ...le_database_get_with_expand_equals_keys.py | 2 +- .../recoverable_database_list.py | 2 +- .../refresh_external_governance_status.py | 2 +- ... refresh_external_governance_status_mi.py} | 12 +- .../replication_link_delete.py | 2 +- .../replication_link_failover.py | 2 +- ...plication_link_failover_allow_data_loss.py | 2 +- .../generated_samples/replication_link_get.py | 2 +- .../replication_link_list_by_database.py | 2 +- .../replication_link_list_by_server.py | 2 +- ...p_based_long_term_retention_backup_copy.py | 2 +- ...based_long_term_retention_backup_delete.py | 2 +- ...up_based_long_term_retention_backup_get.py | 2 +- ..._term_retention_backup_list_by_database.py | 2 +- ..._term_retention_backup_list_by_location.py | 2 +- ...ng_term_retention_backup_list_by_server.py | 2 +- ...based_long_term_retention_backup_update.py | 2 +- ...tance_long_term_retention_backup_delete.py | 4 +- ...instance_long_term_retention_backup_get.py | 2 +- ..._term_retention_backup_list_by_database.py | 2 +- ..._term_retention_backup_list_by_instance.py | 2 +- ..._term_retention_backup_list_by_location.py | 2 +- ...naged_database_list_by_managed_instance.py | 2 +- .../sensitivity_labels_current_update.py | 2 +- ...=> sensitivity_labels_list_by_database.py} | 12 +- ...ls_list_by_database_with_source_current.py | 2 +- ...ist_by_database_with_source_recommended.py | 2 +- .../sensitivity_labels_recommended_update.py | 2 +- ...d_threat_protection_settings_create_max.py | 2 +- ...d_threat_protection_settings_create_min.py | 2 +- ...advanced_threat_protection_settings_get.py | 2 +- ...reat_protection_settings_list_by_server.py | 2 +- .../generated_samples/server_advisor_get.py | 2 +- .../generated_samples/server_advisor_list.py | 2 +- .../server_advisor_update.py | 2 +- .../server_auditing_settings_list.py | 2 +- .../server_automatic_tuning_get.py | 2 +- .../server_automatic_tuning_update_max.py | 2 +- .../server_automatic_tuning_update_min.py | 2 +- .../server_blob_auditing_create_max.py | 2 +- .../server_blob_auditing_create_min.py | 2 +- .../server_blob_auditing_get.py | 2 +- .../server_configuration_option_get.py | 2 +- .../server_configuration_option_list.py | 2 +- .../server_configuration_option_update.py | 2 +- .../server_connection_policies_get.py | 2 +- .../server_connection_policies_list.py | 2 +- .../server_connection_policies_update.py | 2 +- .../generated_samples/server_create.py | 3 +- .../generated_samples/server_delete.py | 2 +- .../server_dev_ops_audit_create_max.py | 2 +- .../server_dev_ops_audit_create_min.py | 2 +- .../server_dev_ops_audit_get.py | 2 +- .../server_dev_ops_audit_list.py | 2 +- .../server_dns_alias_acquire.py | 2 +- .../server_dns_alias_create_or_update.py | 2 +- .../server_dns_alias_delete.py | 2 +- .../generated_samples/server_dns_alias_get.py | 2 +- .../server_dns_alias_list.py | 2 +- .../server_extended_auditing_settings_list.py | 2 +- .../generated_samples/server_get.py | 2 +- ...r_get_with_expand_equals_administrators.py | 2 +- .../server_key_create_or_update.py | 2 +- .../generated_samples/server_key_delete.py | 2 +- .../generated_samples/server_key_get.py | 2 +- .../generated_samples/server_key_list.py | 2 +- .../generated_samples/server_list.py | 2 +- .../server_list_by_resource_group.py | 2 +- ...group_with_expand_equals_administrators.py | 2 +- ..._list_with_expand_equals_administrators.py | 2 +- .../server_recommended_action_list_expand.py | 2 +- .../server_security_alerts_create_max.py | 2 +- .../server_security_alerts_create_min.py | 2 +- .../server_security_alerts_get.py | 2 +- .../server_security_alerts_list_by_server.py | 2 +- .../server_trust_certificates_create.py | 2 +- .../server_trust_certificates_delete.py | 2 +- .../server_trust_certificates_get.py | 2 +- ...ver_trust_certificates_list_by_instance.py | 2 +- .../server_trust_group_create.py | 2 +- .../server_trust_group_delete.py | 2 +- .../server_trust_group_get.py | 2 +- .../server_trust_group_list.py | 2 +- ...er_trust_group_list_by_managed_instance.py | 2 +- .../generated_samples/server_update.py | 3 +- ...e_metrics_list.py => server_usage_list.py} | 4 +- ...assessment_create_container_sas_key_min.py | 2 +- ...ver_vulnerability_assessment_create_max.py | 2 +- ...ssessment_create_storage_access_key_min.py | 2 +- .../server_vulnerability_assessment_delete.py | 2 +- .../server_vulnerability_assessment_get.py | 2 +- ...vulnerability_assessment_list_by_server.py | 2 +- .../sql_agent_configuration_get.py | 2 +- .../sql_agent_configuration_put.py | 2 +- .../sql_tde_certificate_create.py | 2 +- ...l_vulnerability_assessment_baseline_add.py | 2 +- ...rability_assessment_baseline_add_latest.py | 2 +- ...l_vulnerability_assessment_baseline_get.py | 2 +- ...ne_list_by_sql_vulnerability_assessment.py | 2 +- .../sql_vulnerability_assessment_create.py | 2 +- .../sql_vulnerability_assessment_delete.py | 2 +- .../sql_vulnerability_assessment_get.py | 2 +- ...vulnerability_assessment_list_by_server.py | 2 +- ...erability_assessment_list_scans_results.py | 2 +- ...ability_assessment_rule_baseline_create.py | 2 +- ...ability_assessment_rule_baseline_delete.py | 2 +- ...nerability_assessment_rule_baseline_get.py | 2 +- ...sessment_rule_baseline_list_by_baseline.py | 2 +- .../sql_vulnerability_assessment_scan.py | 2 +- ...ssessment_scan_records_list_by_database.py | 2 +- ..._vulnerability_assessment_scans_execute.py | 2 +- ..._vulnerability_assessment_scans_results.py | 2 +- .../start_managed_instance.py | 5 +- ..._instance_schedule_create_or_update_max.py | 2 +- ..._instance_schedule_create_or_update_min.py | 2 +- ...t_stop_managed_instance_schedule_delete.py | 2 +- ...tart_stop_managed_instance_schedule_get.py | 2 +- ...art_stop_managed_instance_schedule_list.py | 2 +- .../stop_managed_instance.py | 5 +- .../subscription_usage_get.py | 2 +- .../subscription_usage_list_by_location.py | 2 +- ...synapse_link_workspace_list_by_database.py | 2 +- .../generated_samples/sync_agent_create.py | 2 +- .../generated_samples/sync_agent_delete.py | 2 +- .../sync_agent_generate_key.py | 2 +- .../generated_samples/sync_agent_get.py | 2 +- .../sync_agent_get_linked_databases.py | 2 +- .../sync_agent_list_by_server.py | 2 +- .../generated_samples/sync_agent_update.py | 2 +- .../sync_group_cancel_sync.py | 2 +- .../generated_samples/sync_group_create.py | 2 +- .../generated_samples/sync_group_delete.py | 2 +- .../generated_samples/sync_group_get.py | 2 +- .../sync_group_get_hub_schema.py | 2 +- .../generated_samples/sync_group_get_log.py | 2 +- .../sync_group_get_sync_database_id.py | 2 +- .../sync_group_list_by_database.py | 2 +- .../generated_samples/sync_group_patch.py | 2 +- .../sync_group_refresh_hub_schema.py | 2 +- .../sync_group_trigger_sync.py | 2 +- .../generated_samples/sync_group_update.py | 2 +- .../generated_samples/sync_member_create.py | 2 +- .../generated_samples/sync_member_delete.py | 2 +- .../generated_samples/sync_member_get.py | 2 +- .../sync_member_get_schema.py | 2 +- .../sync_member_list_by_sync_group.py | 2 +- .../generated_samples/sync_member_patch.py | 2 +- .../sync_member_refresh_schema.py | 2 +- .../generated_samples/sync_member_update.py | 2 +- .../transparent_data_encryption_get.py | 2 +- .../transparent_data_encryption_list.py | 2 +- .../transparent_data_encryption_update.py | 2 +- .../generated_samples/update_job_agent.py | 2 +- ...ate_managed_short_term_retention_policy.py | 2 +- ...erm_retention_policy_restorable_dropped.py | 2 +- .../update_short_term_retention_policy.py | 2 +- .../update_virtual_cluster_dns_servers.py | 2 +- .../virtual_cluster_delete.py | 2 +- .../generated_samples/virtual_cluster_get.py | 2 +- .../generated_samples/virtual_cluster_list.py | 2 +- .../virtual_cluster_list_by_resource_group.py | 2 +- .../virtual_cluster_update.py | 2 +- .../virtual_network_rules_create_or_update.py | 2 +- .../virtual_network_rules_delete.py | 2 +- .../virtual_network_rules_get.py | 2 +- .../virtual_network_rules_list.py | 2 +- 914 files changed, 25992 insertions(+), 22445 deletions(-) delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py create mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_network_security_perimeter_configurations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py rename sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/{_server_communication_links_operations.py => _network_security_perimeter_configurations_operations.py} (50%) delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py rename sdk/sql/azure-mgmt-sql/generated_samples/{data_masking_rule_list.py => data_masking_rule_list_by_database.py} (89%) rename sdk/sql/azure-mgmt-sql/generated_samples/{elastic_pool_metrics_definitions_list.py => distributed_availability_groups_set_role.py} (74%) delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py rename sdk/sql/azure-mgmt-sql/generated_samples/{service_objective_list.py => list_operations.py} (81%) rename sdk/sql/azure-mgmt-sql/generated_samples/{elastic_pool_activity_list.py => managed_database_sensitivity_labels_list_by_database.py} (78%) rename sdk/sql/azure-mgmt-sql/generated_samples/{service_objective_get.py => managed_instance_long_term_retention_policy_delete.py} (75%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/network_security_perimeter_configurations_get.py rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_list.py => network_security_perimeter_configurations_list_by_server.py} (82%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_create_or_update.py => network_security_perimeter_configurations_reconcile.py} (79%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_get.py => outbound_firewall_rule_create.py} (84%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_delete.py => refresh_external_governance_status_mi.py} (82%) rename sdk/sql/azure-mgmt-sql/generated_samples/{database_metrics_definitions_list.py => sensitivity_labels_list_by_database.py} (82%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_usage_metrics_list.py => server_usage_list.py} (93%) diff --git a/sdk/sql/azure-mgmt-sql/_meta.json b/sdk/sql/azure-mgmt-sql/_meta.json index e67f45afc4a6..853891c883ce 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -1,11 +1,11 @@ { - "commit": "3e3098d6b9302e166b611ce72b3392786d3ea0f7", + "commit": "06ef8c1cce2b9769af44c310e3a3e7d244ea8541", "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..4523d9c9a897 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-02-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-02-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..eb2d128be185 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, @@ -109,6 +107,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -127,7 +126,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -140,7 +138,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -177,34 +174,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 +224,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 +296,6 @@ 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_step_executions: JobStepExecutionsOperations operations :vartype job_step_executions: azure.mgmt.sql.operations.JobStepExecutionsOperations :ivar job_steps: JobStepsOperations operations @@ -257,8 +306,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 +331,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 +354,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 +372,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 +423,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 +488,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,161 +506,19 @@ 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 sql_agent: SqlAgentOperations operations - :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations - :ivar subscription_usages: SubscriptionUsagesOperations operations - :vartype subscription_usages: azure.mgmt.sql.operations.SubscriptionUsagesOperations - :ivar sync_agents: SyncAgentsOperations operations - :vartype sync_agents: azure.mgmt.sql.operations.SyncAgentsOperations - :ivar sync_groups: SyncGroupsOperations operations - :vartype sync_groups: azure.mgmt.sql.operations.SyncGroupsOperations - :ivar sync_members: SyncMembersOperations operations - :vartype sync_members: azure.mgmt.sql.operations.SyncMembersOperations - :ivar tde_certificates: TdeCertificatesOperations operations - :vartype tde_certificates: azure.mgmt.sql.operations.TdeCertificatesOperations - :ivar time_zones: TimeZonesOperations operations - :vartype time_zones: azure.mgmt.sql.operations.TimeZonesOperations - :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_agent: SqlAgentOperations operations + :vartype sql_agent: azure.mgmt.sql.operations.SqlAgentOperations :ivar sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations operations :vartype sql_vulnerability_assessment_baseline: @@ -569,36 +553,46 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :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 + :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 + :vartype sync_groups: azure.mgmt.sql.operations.SyncGroupsOperations + :ivar sync_members: SyncMembersOperations operations + :vartype sync_members: azure.mgmt.sql.operations.SyncMembersOperations + :ivar tde_certificates: TdeCertificatesOperations operations + :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 :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-02-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,30 +613,33 @@ 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.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service_objectives = ServiceObjectivesOperations( + self.data_masking_policies = DataMaskingPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_activities = ElasticPoolActivitiesOperations( + self.data_masking_rules = DataMaskingRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.elastic_pool_database_activities = ElasticPoolDatabaseActivitiesOperations( + self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( 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._client, self._config, self._serialize, self._deserialize ) @@ -652,6 +649,15 @@ def __init__( self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_extensions = DatabaseExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_operations = DatabaseOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -661,32 +667,69 @@ def __init__( self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + 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.database_sql_vulnerability_assessment_rule_baselines = ( + DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) 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.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( + self.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.elastic_pool_operations = ElasticPoolOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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.endpoint_certificates = EndpointCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + 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.deleted_servers = DeletedServersOperations(self._client, self._config, self._serialize, self._deserialize) - self.elastic_pool_operations = ElasticPoolOperationsOperations( + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.encryption_protectors = EncryptionProtectorsOperations( + self.instance_failover_groups = InstanceFailoverGroupsOperations( 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 ) @@ -698,7 +741,17 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) 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.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.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -711,12 +764,23 @@ def __init__( self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( 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_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -726,6 +790,12 @@ def __init__( self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -737,18 +807,29 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) ) + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( 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.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -773,206 +854,102 @@ def __init__( self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_dns_aliases = ServerDnsAliasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_trust_groups = ServerTrustGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sync_agents = SyncAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sync_members = SyncMembersOperations(self._client, self._config, self._serialize, self._deserialize) - self.tde_certificates = TdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( 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_restorable_dropped_database_backup_short_term_retention_policies = ( + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.database_extensions = DatabaseExtensionsOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( 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.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) + 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.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) self.sensitivity_labels = SensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( - 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._client, self._config, self._serialize, self._deserialize - ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + 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.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instances = ManagedInstancesOperations( + 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.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_configuration_options = ServerConfigurationOptionsOperations( + 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.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - 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._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 +977,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..6dfcfd40dfeb 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-02-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-02-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..51035cdafb97 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, @@ -109,6 +107,7 @@ ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations, ManagedServerDnsAliasesOperations, ManagedServerSecurityAlertPoliciesOperations, + NetworkSecurityPerimeterConfigurationsOperations, Operations, OutboundFirewallRulesOperations, PrivateEndpointConnectionsOperations, @@ -127,7 +126,6 @@ ServerAzureADAdministratorsOperations, ServerAzureADOnlyAuthenticationsOperations, ServerBlobAuditingPoliciesOperations, - ServerCommunicationLinksOperations, ServerConfigurationOptionsOperations, ServerConnectionPoliciesOperations, ServerDevOpsAuditSettingsOperations, @@ -140,7 +138,6 @@ ServerUsagesOperations, ServerVulnerabilityAssessmentsOperations, ServersOperations, - ServiceObjectivesOperations, SqlAgentOperations, SqlVulnerabilityAssessmentBaselineOperations, SqlVulnerabilityAssessmentBaselinesOperations, @@ -177,28 +174,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 +210,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 +225,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 +298,6 @@ 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_step_executions: JobStepExecutionsOperations operations :vartype job_step_executions: azure.mgmt.sql.aio.operations.JobStepExecutionsOperations :ivar job_steps: JobStepsOperations operations @@ -258,8 +308,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 +333,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 +359,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 +377,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 +428,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 +493,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 +511,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 +577,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-02-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,30 +619,33 @@ 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.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( 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._client, self._config, self._serialize, self._deserialize ) @@ -658,6 +655,15 @@ def __init__( self.database_columns = DatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_extensions = DatabaseExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_operations = DatabaseOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.database_recommended_actions = DatabaseRecommendedActionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -667,32 +673,69 @@ def __init__( self.database_security_alert_policies = DatabaseSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_tables = DatabaseTablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_vulnerability_assessment_rule_baselines = DatabaseVulnerabilityAssessmentRuleBaselinesOperations( + self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( + self.database_sql_vulnerability_assessment_execute_scan = ( + DatabaseSqlVulnerabilityAssessmentExecuteScanOperations( + 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.database_sql_vulnerability_assessment_scan_result = DatabaseSqlVulnerabilityAssessmentScanResultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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.database_vulnerability_assessment_scans = DatabaseVulnerabilityAssessmentScansOperations( self._client, self._config, self._serialize, self._deserialize ) - self.data_warehouse_user_activities = DataWarehouseUserActivitiesOperations( + self.database_vulnerability_assessments = DatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) + 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.elastic_pool_operations = ElasticPoolOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) + 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.endpoint_certificates = EndpointCertificatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.failover_groups = FailoverGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.geo_backup_policies = GeoBackupPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.instance_failover_groups = InstanceFailoverGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.instance_pools = InstancePoolsOperations(self._client, self._config, self._serialize, self._deserialize) self.job_agents = JobAgentsOperations(self._client, self._config, self._serialize, self._deserialize) self.job_credentials = JobCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) self.job_executions = JobExecutionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.job_step_executions = JobStepExecutionsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -704,7 +747,17 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) 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.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.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.long_term_retention_policies = LongTermRetentionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -717,12 +770,23 @@ def __init__( self.managed_backup_short_term_retention_policies = ManagedBackupShortTermRetentionPoliciesOperations( 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_database_columns = ManagedDatabaseColumnsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_queries = ManagedDatabaseQueriesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_schemas = ManagedDatabaseSchemasOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -732,6 +796,12 @@ def __init__( self.managed_database_security_events = ManagedDatabaseSecurityEventsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_tables = ManagedDatabaseTablesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -743,18 +813,29 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) ) + self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_database_vulnerability_assessments = ManagedDatabaseVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_vulnerability_assessment_scans = ManagedDatabaseVulnerabilityAssessmentScansOperations( + self.managed_databases = ManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) self.managed_instance_administrators = ManagedInstanceAdministratorsOperations( 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.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.managed_instance_encryption_protectors = ManagedInstanceEncryptionProtectorsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -779,206 +860,102 @@ def __init__( self.managed_instance_vulnerability_assessments = ManagedInstanceVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_restorable_dropped_database_backup_short_term_retention_policies = ( - ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - ) - self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_advisors = ServerAdvisorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_automatic_tuning = ServerAutomaticTuningOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_dns_aliases = ServerDnsAliasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.server_operations = ServerOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_trust_groups = ServerTrustGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_usages = SubscriptionUsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sync_agents = SyncAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sync_groups = SyncGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sync_members = SyncMembersOperations(self._client, self._config, self._serialize, self._deserialize) - self.tde_certificates = TdeCertificatesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.time_zones = TimeZonesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_network_rules = VirtualNetworkRulesOperations( + self.managed_instances = ManagedInstancesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workload_classifiers = WorkloadClassifiersOperations( + self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( 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_restorable_dropped_database_backup_short_term_retention_policies = ( + ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) ) - self.database_extensions = DatabaseExtensionsOperations( + self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_operations = DatabaseOperationsOperations( + self.managed_server_security_alert_policies = ManagedServerSecurityAlertPoliciesOperations( 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.network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize ) + 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.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.long_term_retention_backups = LongTermRetentionBackupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.long_term_retention_managed_instance_backups = LongTermRetentionManagedInstanceBackupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.recoverable_managed_databases = RecoverableManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.endpoint_certificates = EndpointCertificatesOperations( + self.replication_links = ReplicationLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_sensitivity_labels = ManagedDatabaseSensitivityLabelsOperations( + self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_recommended_sensitivity_labels = ManagedDatabaseRecommendedSensitivityLabelsOperations( + self.restorable_dropped_managed_databases = RestorableDroppedManagedDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) self.sensitivity_labels = SensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) self.recommended_sensitivity_labels = RecommendedSensitivityLabelsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_blob_auditing_policies = ServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( - 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._client, self._config, self._serialize, self._deserialize - ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + 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.synapse_link_workspaces = SynapseLinkWorkspacesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_databases = ManagedDatabasesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instances = ManagedInstancesOperations( + 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.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.recoverable_databases = RecoverableDatabasesOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + self.server_trust_groups = ServerTrustGroupsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_configuration_options = ServerConfigurationOptionsOperations( + 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.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( - 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._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 +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) -> 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..2ecdac5f7314 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,109 @@ # 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_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 +121,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 +168,105 @@ 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", "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 +275,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 +320,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..2c211ffe524b 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 @@ -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..63525d62258a 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( @@ -219,7 +232,7 @@ async def _create_or_update_initial( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO], + parameters: Union[_models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, IO], **kwargs: Any ) -> Optional[_models.DistributedAvailabilityGroup]: error_map = { @@ -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) @@ -243,7 +256,7 @@ async def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupsCreateOrUpdateRequestBody") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -294,7 +307,7 @@ async def begin_create_or_update( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, + parameters: _models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, *, content_type: str = "application/json", **kwargs: Any @@ -309,7 +322,7 @@ async def begin_create_or_update( :param distributed_availability_group_name: The distributed availability group name. Required. :type distributed_availability_group_name: str :param parameters: The distributed availability group info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -372,7 +385,7 @@ async def begin_create_or_update( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO], + parameters: Union[_models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, IO], **kwargs: Any ) -> AsyncLROPoller[_models.DistributedAvailabilityGroup]: """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. @@ -385,8 +398,9 @@ async def begin_create_or_update( :param distributed_availability_group_name: The distributed availability group name. Required. :type distributed_availability_group_name: str :param parameters: The distributed availability group info. Is either a - DistributedAvailabilityGroup type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO + DistributedAvailabilityGroupsCreateOrUpdateRequestBody type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody + or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -406,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", "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 +484,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 +550,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 +610,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 +780,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 +825,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/_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..d04e4ed905a9 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 ( @@ -70,15 +71,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 +109,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 +293,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 +530,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 +538,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 +564,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,17 +583,17 @@ 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 _copy_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.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { @@ -337,7 +607,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-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) @@ -347,9 +617,9 @@ async def _update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") + _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") - request = build_update_request( + 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, @@ -359,7 +629,7 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], + template_url=self._copy_initial.metadata["url"], headers=_headers, params=_params, ) @@ -386,23 +656,23 @@ async def _update_initial( return deserialized - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" + _copy_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } @overload - async def begin_update( + 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.UpdateLongTermRetentionBackupParameters, + parameters: _models.CopyLongTermRetentionBackupParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -412,8 +682,8 @@ async 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. Required. - :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :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 @@ -433,7 +703,7 @@ async def begin_update( """ @overload - async def begin_update( + async def begin_copy( self, location_name: str, long_term_retention_server_name: str, @@ -444,7 +714,7 @@ async def begin_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -454,7 +724,7 @@ async 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. Required. + :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". @@ -475,16 +745,16 @@ async def begin_update( """ @distributed_trace_async - async def begin_update( + 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.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -494,9 +764,9 @@ async 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 + :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 @@ -517,14 +787,14 @@ 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-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, 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._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, @@ -560,34 +830,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_copy.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace_async - async def get( + async def _update_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], **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 +851,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, "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, - template_url=self.get.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -623,85 +890,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}" + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } - async def _delete_initial( # pylint: disable=inconsistent-return-statements + @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 - ) -> 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]: + """Updates 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 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: + """ - if cls: - return cls(pipeline_response, None, {}) + @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. - _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 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_delete( + 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[None]: - """Deletes a long term retention backup. + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -711,6 +1011,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 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 @@ -719,25 +1025,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._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, @@ -745,9 +1056,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,28 +1077,26 @@ 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_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } @distributed_trace - def list_by_database( + 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, only_latest_per_database: Optional[bool] = None, database_state: Optional[Union[str, _models.DatabaseState]] = None, **kwargs: Any ) -> AsyncIterable["_models.LongTermRetentionBackup"]: - """Lists all long term retention backups for a database. + """Lists the long term retention backups for a given location. + :param resource_group_name: The name of the resource group that contains the resource. You can + 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 @@ -801,7 +1112,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 +1126,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 +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" @@ -861,22 +1182,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. + :param resource_group_name: The name of the resource group that 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 +1220,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 +1234,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 +1250,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 +1291,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. + :param resource_group_name: The name of the resource group that 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 +1332,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 +1346,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 +1363,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 +1404,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 +1444,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 +1458,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 +1472,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 +1566,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 +1574,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 +1601,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,18 +1620,18 @@ 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 _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.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> Optional[_models.LongTermRetentionBackupOperationResult]: error_map = { @@ -1330,7 +1645,7 @@ 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) @@ -1340,9 +1655,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, "CopyLongTermRetentionBackupParameters") - request = build_update_by_resource_group_request( + 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, @@ -1353,7 +1668,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._copy_by_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1380,24 +1695,24 @@ async def _update_by_resource_group_initial( 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" + _copy_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } @overload - async def begin_update_by_resource_group( + 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.UpdateLongTermRetentionBackupParameters, + parameters: _models.CopyLongTermRetentionBackupParameters, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """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. @@ -1410,8 +1725,8 @@ async def begin_update_by_resource_group( :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 + :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 @@ -1431,7 +1746,7 @@ async def begin_update_by_resource_group( """ @overload - async def begin_update_by_resource_group( + async def begin_copy_by_resource_group( self, resource_group_name: str, location_name: str, @@ -1443,7 +1758,7 @@ async def begin_update_by_resource_group( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """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. @@ -1456,7 +1771,7 @@ async def begin_update_by_resource_group( :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. + :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". @@ -1477,17 +1792,17 @@ async def begin_update_by_resource_group( """ @distributed_trace_async - async def begin_update_by_resource_group( + 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: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """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. @@ -1500,9 +1815,9 @@ async def begin_update_by_resource_group( :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 + :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 @@ -1523,14 +1838,14 @@ async def begin_update_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, 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._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, @@ -1567,38 +1882,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_copy_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace_async - async def get_by_resource_group( + 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 - ) -> _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 +1904,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, "UpdateLongTermRetentionBackupParameters") + + 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, @@ -1621,7 +1927,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._update_by_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1635,88 +1944,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}" + _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_async - async def begin_delete_by_resource_group( + @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: _models.UpdateLongTermRetentionBackupParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a long term retention backup. + ) -> 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. @@ -1729,6 +1987,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 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 @@ -1737,68 +2000,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_update_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]: + """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. @@ -1809,191 +2031,40 @@ 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 - :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", "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( - 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. - - :param resource_group_name: The name of the resource group that 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 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 - :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_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("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_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" - } - - @distributed_trace - def list_by_resource_group_server( + @distributed_trace_async + 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: Union[_models.UpdateLongTermRetentionBackupParameters, IO], **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 +2073,77 @@ 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. 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 - :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) - - 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_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: - 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..7810ebed4adc 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,216 @@ 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, + **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 + :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, + 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 +306,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 +359,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 +423,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 +466,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 +496,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 +510,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 +525,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,25 +566,26 @@ 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, **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 @@ -383,7 +602,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 +616,14 @@ 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, 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 +631,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 +672,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 +714,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 +728,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 +745,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 +786,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 +829,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 +889,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 +963,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 +1006,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 +1041,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 +1071,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 +1115,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..da30db1d325a 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) @@ -219,7 +315,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -261,7 +357,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -301,7 +397,7 @@ async def begin_create_or_update( parameters: Union[_models.LongTermRetentionPolicy, IO], **kwargs: Any ) -> AsyncLROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -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..3778e073d7ce 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,138 @@ 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 + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + 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 +1352,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 +1372,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 +1388,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 +1413,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 +1440,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 +1454,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 +1476,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 +1496,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 +1512,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 +1537,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 +1612,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 +1646,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_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py deleted file mode 100644 index cb94d2cb128f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py +++ /dev/null @@ -1,507 +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 io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -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._server_communication_links_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_server_request, -) - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ServerCommunicationLinksOperations: - """ - .. 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. - """ - - 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 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. - - :param resource_group_name: The name of the resource group that 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 - :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", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - - 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) - - _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/servers/{serverName}/communicationLinks/{communicationLinkName}" - } - - @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. - - :param resource_group_name: The name of the resource group that 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 - :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 - :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.ServerCommunicationLink] = kwargs.pop("cls", None) - - request = build_get_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.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("ServerCommunicationLink", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" - } - - async def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], - **kwargs: Any - ) -> Optional[_models.ServerCommunicationLink]: - 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", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerCommunicationLink]] = 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, "ServerCommunicationLink") - - request = build_create_or_update_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, - 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) - - _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 [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 == 201: - deserialized = self._deserialize("ServerCommunicationLink", 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}/communicationLinks/{communicationLinkName}" - } - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: _models.ServerCommunicationLink, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. - - :param resource_group_name: The name of the resource group that 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 - :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 ServerCommunicationLink or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. - - :param resource_group_name: The name of the resource group that 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: 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 ServerCommunicationLink or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. - - :param resource_group_name: The name of the resource group that 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 - :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 ServerCommunicationLink or the - result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :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")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ServerCommunicationLink] = 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( - resource_group_name=resource_group_name, - server_name=server_name, - communication_link_name=communication_link_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("ServerCommunicationLink", 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_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" - } - - @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) - - 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("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) - - 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}/communicationLinks" - } 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..836e9dfea581 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,7 @@ from ._models_py3 import Baseline from ._models_py3 import BaselineAdjustedResult from ._models_py3 import BenchmarkReference +from ._models_py3 import CertificateInfo from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResponse from ._models_py3 import CompleteDatabaseRestoreDefinition @@ -65,13 +66,12 @@ 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 DistributedAvailabilityGroupsCreateOrUpdateRequestBody 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 @@ -229,22 +233,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 @@ -253,6 +259,7 @@ from ._models_py3 import PartnerInfo from ._models_py3 import PartnerRegionInfo 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 @@ -283,6 +290,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 +321,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 +349,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 +397,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 @@ -437,12 +440,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 @@ -462,12 +467,16 @@ from ._sql_management_client_enums import ExternalGovernanceStatus from ._sql_management_client_enums import FailoverGroupReplicationRole 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 JobAgentState from ._sql_management_client_enums import JobExecutionLifecycle @@ -479,6 +488,7 @@ 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 @@ -486,7 +496,6 @@ from ._sql_management_client_enums import ManagedInstanceAdministratorType 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 +509,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 +522,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,6 +539,7 @@ 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 @@ -540,13 +553,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 +573,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 +594,7 @@ "Baseline", "BaselineAdjustedResult", "BenchmarkReference", + "CertificateInfo", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "CompleteDatabaseRestoreDefinition", @@ -632,13 +643,12 @@ "DeletedServer", "DeletedServerListResult", "DistributedAvailabilityGroup", + "DistributedAvailabilityGroupDatabase", + "DistributedAvailabilityGroupSetRole", + "DistributedAvailabilityGroupsCreateOrUpdateRequestBody", "DistributedAvailabilityGroupsListResult", "EditionCapability", "ElasticPool", - "ElasticPoolActivity", - "ElasticPoolActivityListResult", - "ElasticPoolDatabaseActivity", - "ElasticPoolDatabaseActivityListResult", "ElasticPoolEditionCapability", "ElasticPoolListResult", "ElasticPoolOperation", @@ -654,6 +664,9 @@ "EndpointCertificateListResult", "EndpointDependency", "EndpointDetail", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ExportDatabaseDefinition", "ExtendedDatabaseBlobAuditingPolicy", "ExtendedDatabaseBlobAuditingPolicyListResult", @@ -667,6 +680,7 @@ "FirewallRule", "FirewallRuleList", "FirewallRuleListResult", + "FreeLimitExhaustionBehaviorCapability", "GeoBackupPolicy", "GeoBackupPolicyListResult", "IPv6FirewallRule", @@ -796,22 +810,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", @@ -820,6 +836,7 @@ "PartnerInfo", "PartnerRegionInfo", "PerformanceLevelCapability", + "PhaseDetails", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", "PrivateEndpointConnectionProperties", @@ -850,6 +867,7 @@ "RecoverableManagedDatabase", "RecoverableManagedDatabaseListResult", "RefreshExternalGovernanceStatusOperationResult", + "RefreshExternalGovernanceStatusOperationResultMI", "Remediation", "ReplicationLink", "ReplicationLinkListResult", @@ -880,8 +898,6 @@ "ServerAzureADOnlyAuthentication", "ServerBlobAuditingPolicy", "ServerBlobAuditingPolicyListResult", - "ServerCommunicationLink", - "ServerCommunicationLinkListResult", "ServerConfigurationOption", "ServerConfigurationOptionListResult", "ServerConnectionPolicy", @@ -910,12 +926,9 @@ "ServerVersionCapability", "ServerVulnerabilityAssessment", "ServerVulnerabilityAssessmentListResult", - "ServiceObjective", "ServiceObjectiveCapability", - "ServiceObjectiveListResult", "ServicePrincipal", "Sku", - "SloUsageMetric", "SqlAgentConfiguration", "SqlVulnerabilityAssessment", "SqlVulnerabilityAssessmentListResult", @@ -961,7 +974,7 @@ "UpdateLongTermRetentionBackupParameters", "UpdateVirtualClusterDnsServersOperation", "UpsertManagedServerOperationParameters", - "UpsertManagedServerOperationStep", + "UpsertManagedServerOperationStepWithEstimatesAndDuration", "Usage", "UsageListResult", "UserIdentity", @@ -1003,12 +1016,14 @@ "CapabilityStatus", "CatalogCollationType", "CheckNameAvailabilityReason", + "ClientClassificationSource", "ColumnDataType", "ConnectionPolicyName", "CreateMode", "CreatedByType", "DNSRefreshOperationStatus", "DataMaskingFunction", + "DataMaskingPolicyName", "DataMaskingRuleState", "DataMaskingState", "DataWarehouseUserActivityName", @@ -1028,12 +1043,16 @@ "ExternalGovernanceStatus", "FailoverGroupReplicationRole", "FreeLimitExhaustionBehavior", + "FreemiumType", "GeoBackupPolicyName", "GeoBackupPolicyState", + "HybridSecondaryUsage", + "HybridSecondaryUsageDetected", "IdentityType", "ImplementationMethod", "InstanceFailoverGroupReplicationRole", "InstancePoolLicenseType", + "InstanceRole", "IsRetryable", "JobAgentState", "JobExecutionLifecycle", @@ -1045,6 +1064,7 @@ "JobTargetType", "LedgerDigestUploadsName", "LedgerDigestUploadsState", + "LinkRole", "LogSizeUnit", "LongTermRetentionPolicyName", "ManagedDatabaseCreateMode", @@ -1052,7 +1072,6 @@ "ManagedInstanceAdministratorType", "ManagedInstanceLicenseType", "ManagedInstanceLongTermRetentionPolicyName", - "ManagedInstancePropertiesProvisioningState", "ManagedInstanceProxyOverride", "ManagedLedgerDigestUploadsName", "ManagedLedgerDigestUploadsState", @@ -1066,7 +1085,7 @@ "OperationOrigin", "PauseDelayTimeUnit", "PerformanceLevelUnit", - "PrimaryAggregationType", + "Phase", "PrincipalType", "PrivateEndpointProvisioningState", "PrivateLinkServiceConnectionStateActionsRequire", @@ -1079,13 +1098,16 @@ "RecommendedActionCurrentState", "RecommendedActionInitiatedBy", "RecommendedSensitivityLabelUpdateKind", + "ReplicaConnectedState", + "ReplicaSynchronizationHealth", "ReplicaType", "ReplicationLinkType", - "ReplicationMode", + "ReplicationModeType", "ReplicationRole", "ReplicationState", "RestoreDetailsName", "RestorePointType", + "RoleChangeType", "RuleSeverity", "RuleStatus", "RuleType", @@ -1093,6 +1115,7 @@ "SecondaryInstanceType", "SecondaryType", "SecurityAlertPolicyName", + "SecurityAlertPolicyNameAutoGenerated", "SecurityAlertPolicyState", "SecurityAlertsPolicyState", "SecurityEventType", @@ -1106,13 +1129,13 @@ "ServerPublicNetworkAccessFlag", "ServerTrustGroupPropertiesTrustScopesItem", "ServerWorkspaceFeature", - "ServiceObjectiveName", "ServicePrincipalType", "ShortTermRetentionPolicyName", "SqlAgentConfigurationPropertiesState", "SqlVulnerabilityAssessmentName", "SqlVulnerabilityAssessmentState", "StartStopScheduleName", + "Status", "StorageCapabilityStorageAccountType", "StorageKeyType", "SyncAgentState", @@ -1126,9 +1149,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..add57b3f7127 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,39 @@ 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 certificate_id: The certificate ID. + :vartype certificate_id: str + :ivar expiry_date: The certificate expiry date. + :vartype expiry_date: ~datetime.datetime + """ + + _validation = { + "certificate_name": {"readonly": True}, + "certificate_id": {"readonly": True}, + "expiry_date": {"readonly": True}, + } + + _attribute_map = { + "certificate_name": {"key": "certificateName", "type": "str"}, + "certificate_id": {"key": "certificateId", "type": "str"}, + "expiry_date": {"key": "expiryDate", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.certificate_name = None + self.certificate_id = None + self.expiry_date = None + + class CheckNameAvailabilityRequest(_serialization.Model): """A request to check whether the specified name for a resource is available. @@ -2017,8 +2050,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 +2061,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 +2104,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 +2120,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 +2321,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 +2343,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 +2364,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 +2384,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 +3574,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 +3622,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 +3779,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 +3791,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 +3837,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 +3855,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 +3871,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 +3883,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 +3921,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 +3937,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 +3951,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 +3963,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 +3988,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 +4002,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,54 +4181,221 @@ 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 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}, + "partner_availability_group_name": {"readonly": True}, + "partner_endpoint": {"readonly": True}, + "instance_link_role": {"readonly": True}, + "instance_availability_group_name": {"readonly": True}, + "databases": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "distributed_availability_group_name": {"key": "properties.distributedAvailabilityGroupName", "type": "str"}, + "distributed_availability_group_id": {"key": "properties.distributedAvailabilityGroupId", "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"}, + "databases": {"key": "properties.databases", "type": "[DistributedAvailabilityGroupDatabase]"}, + } + + def __init__( + self, *, replication_mode: Optional[Union[str, "_models.ReplicationModeType"]] = None, **kwargs: Any + ) -> None: + """ + :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 + """ + super().__init__(**kwargs) + self.distributed_availability_group_name = None + self.distributed_availability_group_id = None + self.replication_mode = replication_mode + self.partner_link_role = None + self.partner_availability_group_name = None + self.partner_endpoint = None + self.instance_link_role = None + self.instance_availability_group_name = None + self.databases = None + + +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 = { + "database_name": {"readonly": True}, + "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, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.database_name = None + 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 DistributedAvailabilityGroupsCreateOrUpdateRequestBody(_serialization.Model): + """Information for creating and updating distributed availability group. + + :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.ReplicationModeType + """ + + _attribute_map = { "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_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"}, } def __init__( @@ -4130,7 +4405,7 @@ def __init__( 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, **kwargs: Any ) -> None: """ @@ -4144,7 +4419,7 @@ def __init__( :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 + :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationModeType """ super().__init__(**kwargs) self.target_database = target_database @@ -4152,11 +4427,49 @@ def __init__( self.primary_availability_group_name = primary_availability_group_name self.secondary_availability_group_name = secondary_availability_group_name self.replication_mode = replication_mode - self.distributed_availability_group_id = None - self.source_replica_id = None - self.target_replica_id = None - self.link_state = None - self.last_hardened_lsn = 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 +4518,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 +4533,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 +4546,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 +4562,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 @@ -4418,357 +4736,58 @@ def __init__( 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 - """ - 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 - - -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 + :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.zone_pinning = None self.status = None self.reason = reason @@ -5479,6 +5498,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 +6527,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 +6615,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 +6624,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 +6634,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 +6646,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,37 +6829,63 @@ 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 id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. - :vartype kind: str - :ivar location: Backup policy location. - :vartype location: str - :ivar state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". - :vartype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState - :ivar storage_type: The storage type of the geo backup policy. - :vartype storage_type: str + :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 = { - "id": {"readonly": True}, - "name": {"readonly": True}, + "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 + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Backup policy location. + :vartype location: str + :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 + """ + + _validation = { + "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 +6893,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. + + Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of geo backup policies. + :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 +7047,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 +7072,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 +7093,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 +7109,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 +7127,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 +7244,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 +7266,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 +7282,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 +7309,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 @@ -7608,7 +7789,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 +7820,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) @@ -8131,8 +8312,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, @@ -9006,6 +9187,8 @@ 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 """ _validation = { @@ -9033,12 +9216,14 @@ 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"}, } def __init__( self, *, requested_backup_storage_redundancy: Optional[Union[str, "_models.BackupStorageRedundancy"]] = None, + is_backup_immutable: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -9046,6 +9231,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 +9243,7 @@ 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 class LongTermRetentionBackupListResult(_serialization.Model): @@ -9164,6 +9352,8 @@ class LongTermRetentionPolicy(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar make_backups_immutable: The setting whether to make LTR backups immutable. + :vartype make_backups_immutable: bool :ivar weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. :vartype weekly_retention: str :ivar monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 format. @@ -9184,6 +9374,7 @@ class LongTermRetentionPolicy(ProxyResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "make_backups_immutable": {"key": "properties.makeBackupsImmutable", "type": "bool"}, "weekly_retention": {"key": "properties.weeklyRetention", "type": "str"}, "monthly_retention": {"key": "properties.monthlyRetention", "type": "str"}, "yearly_retention": {"key": "properties.yearlyRetention", "type": "str"}, @@ -9193,6 +9384,7 @@ class LongTermRetentionPolicy(ProxyResource): def __init__( self, *, + make_backups_immutable: Optional[bool] = None, weekly_retention: Optional[str] = None, monthly_retention: Optional[str] = None, yearly_retention: Optional[str] = None, @@ -9200,6 +9392,8 @@ def __init__( **kwargs: Any ) -> None: """ + :keyword make_backups_immutable: The setting whether to make LTR backups immutable. + :paramtype make_backups_immutable: bool :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. :paramtype weekly_retention: str :keyword monthly_retention: The monthly retention policy for an LTR backup in an ISO 8601 @@ -9211,6 +9405,7 @@ def __init__( :paramtype week_of_year: int """ super().__init__(**kwargs) + self.make_backups_immutable = make_backups_immutable self.weekly_retention = weekly_retention self.monthly_retention = monthly_retention self.yearly_retention = yearly_retention @@ -10723,11 +10918,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 +10931,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 +10947,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,6 +11031,17 @@ 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 """ _validation = { @@ -10829,9 +11052,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 +11072,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 +11106,10 @@ 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"}, } def __init__( # pylint: disable=too-many-locals @@ -10884,12 +11120,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 +11146,7 @@ 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, **kwargs: Any ) -> None: """ @@ -10926,6 +11167,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 +11182,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 +11251,9 @@ 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 """ super().__init__(location=location, tags=tags, **kwargs) self.identity = identity @@ -11002,13 +11261,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 +11292,10 @@ 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 class ManagedInstanceAdministrator(ProxyResource): @@ -11473,13 +11741,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 +11757,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 +11779,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 +11959,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 +11975,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 +11984,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 +11999,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 @@ -11967,13 +12240,13 @@ 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 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 """ @@ -12003,14 +12276,13 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword weekly_retention: The weekly retention policy for an LTR backup in an ISO 8601 format. + :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) @@ -12260,7 +12532,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 +12545,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 +12850,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 +12871,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 +12990,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 +13003,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 +13019,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 +13103,30 @@ 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 """ _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 +13136,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 +13170,10 @@ 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"}, } def __init__( # pylint: disable=too-many-locals @@ -12864,12 +13183,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 +13209,7 @@ 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, **kwargs: Any ) -> None: """ @@ -12903,6 +13227,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 +13242,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 +13311,9 @@ 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 """ super().__init__(**kwargs) self.sku = sku @@ -12980,13 +13322,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 +13353,13 @@ 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 -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 +13372,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 +13413,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 +13432,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 +13475,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 +14044,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,396 +14172,522 @@ def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: self.reason = reason -class Metric(_serialization.Model): - """Database metrics. +class MinCapacityCapability(_serialization.Model): + """The min capacity capability. 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] + :ivar value: Min capacity value. + :vartype value: float + :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 = { - "start_time": {"readonly": True}, - "end_time": {"readonly": True}, - "time_grain": {"readonly": True}, - "unit": {"readonly": True}, - "name": {"readonly": True}, - "metric_values": {"readonly": True}, + "value": {"readonly": True}, + "status": {"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]"}, + "value": {"key": "value", "type": "float"}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + 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.start_time = None - self.end_time = None - self.time_grain = None - self.unit = None - self.name = None - self.metric_values = None - + self.value = None + self.status = None + self.reason = reason -class MetricAvailability(_serialization.Model): - """A metric availability value. - Variables are only populated by the server, and will be ignored when sending a request. +class Name(_serialization.Model): + """ARM Usage Name. - :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 + :ivar value: Usage name value. + :vartype value: str + :ivar localized_value: Usage name localized value. + :vartype localized_value: str """ - _validation = { - "retention": {"readonly": True}, - "time_grain": {"readonly": True}, - } - _attribute_map = { - "retention": {"key": "retention", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: Usage name value. + :paramtype value: str + :keyword localized_value: Usage name localized value. + :paramtype localized_value: str + """ super().__init__(**kwargs) - self.retention = None - self.time_grain = None - - -class MetricDefinition(_serialization.Model): - """A database metric definition. + self.value = value + self.localized_value = localized_value - 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] - """ +class NetworkIsolationSettings(_serialization.Model): + """Contains the ARM resources for which to create private endpoint connection. - _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] + :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 """ - _validation = { - "value": {"required": True}, - } - _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, + "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, + "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, } - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: + def __init__( + self, + *, + storage_account_resource_id: Optional[str] = None, + sql_server_resource_id: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword value: The list of metric definitions for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.MetricDefinition] + :keyword storage_account_resource_id: The resource id for the storage account used to store + BACPAC file. If set, private endpoint connection will be created for the storage account. Must + match storage account used for StorageUri parameter. + :paramtype storage_account_resource_id: str + :keyword sql_server_resource_id: The resource id for the SQL server which is the target of this + request. If set, private endpoint connection will be created for the SQL server. Must match + server which is target of the operation. + :paramtype sql_server_resource_id: str """ super().__init__(**kwargs) - self.value = value + self.storage_account_resource_id = storage_account_resource_id + self.sql_server_resource_id = sql_server_resource_id -class MetricListResult(_serialization.Model): - """The response to a list database metrics request. +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """NSP Configuration for a server. - 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 metrics for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.Metric] + :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 = { - "value": {"required": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Metric]"}, + "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, *, value: List["_models.Metric"], **kwargs: Any) -> None: + def __init__( + self, + *, + 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 value: The list of metrics for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.Metric] + :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.value = value + 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 MetricName(_serialization.Model): - """A database metric name. +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: The name of the database metric. - :vartype value: str - :ivar localized_value: The friendly name of the database metric. - :vartype localized_value: str + :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}, - "localized_value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, + "value": {"key": "value", "type": "[NetworkSecurityPerimeterConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None - self.localized_value = None + self.next_link = None -class MetricValue(_serialization.Model): - """Represents database metrics. +class NSPConfigAccessRule(_serialization.Model): + """NSPConfigAccessRule. - 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 + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties """ - _validation = { - "count": {"readonly": True}, - "average": {"readonly": True}, - "maximum": {"readonly": True}, - "minimum": {"readonly": True}, - "timestamp": {"readonly": True}, - "total": {"readonly": True}, + _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 = { - "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"}, + "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, **kwargs: Any) -> None: - """ """ + 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.count = None - self.average = None - self.maximum = None - self.minimum = None - self.timestamp = None - self.total = None + 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 MinCapacityCapability(_serialization.Model): - """The min capacity capability. +class NSPConfigAssociation(_serialization.Model): + """NSPConfigAssociation. - Variables are only populated by the server, and will be ignored when sending a request. + :ivar name: + :vartype name: str + :ivar access_mode: + :vartype access_mode: str + """ - :ivar value: Min capacity value. - :vartype value: float - :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 + _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 """ - _validation = { - "value": {"readonly": True}, - "status": {"readonly": True}, + _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 = { - "value": {"key": "value", "type": "float"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str + :keyword id: + :paramtype id: str + :keyword perimeter_guid: + :paramtype perimeter_guid: str + :keyword location: + :paramtype location: str """ super().__init__(**kwargs) - self.value = None - self.status = None - self.reason = reason + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location -class Name(_serialization.Model): - """ARM Usage Name. +class NSPConfigProfile(_serialization.Model): + """NSPConfigProfile. - :ivar value: Usage name value. - :vartype value: str - :ivar localized_value: Usage name localized value. - :vartype localized_value: str + :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 = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "access_rules_version": {"key": "accessRulesVersion", "type": "str"}, + "access_rules": {"key": "accessRules", "type": "[NSPConfigAccessRule]"}, } - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[str] = None, + access_rules: Optional[List["_models.NSPConfigAccessRule"]] = None, + **kwargs: Any + ) -> None: """ - :keyword value: Usage name value. - :paramtype value: str - :keyword localized_value: Usage name localized value. - :paramtype localized_value: str + :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.value = value - self.localized_value = localized_value + self.name = name + self.access_rules_version = access_rules_version + self.access_rules = access_rules -class NetworkIsolationSettings(_serialization.Model): - """Contains the ARM resources for which to create private endpoint connection. +class NSPProvisioningIssue(_serialization.Model): + """NSPProvisioningIssue. - :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 + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties """ _attribute_map = { - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NSPProvisioningIssueProperties"}, } def __init__( self, *, - storage_account_resource_id: Optional[str] = None, - sql_server_resource_id: Optional[str] = None, + name: Optional[str] = None, + properties: Optional["_models.NSPProvisioningIssueProperties"] = 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 name: + :paramtype name: str + :keyword properties: + :paramtype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties """ super().__init__(**kwargs) - self.storage_account_resource_id = storage_account_resource_id - self.sql_server_resource_id = sql_server_resource_id + self.name = name + self.properties = properties -class NetworkIsolationSettingsAutoGenerated(_serialization.Model): - """Contains the ARM resources for which to create private endpoint connection. +class NSPProvisioningIssueProperties(_serialization.Model): + """NSPProvisioningIssueProperties. - :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 + :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 = { - "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, - "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, + "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, *, - storage_account_resource_id: Optional[str] = None, - sql_server_resource_id: Optional[str] = None, + 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 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 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.storage_account_resource_id = storage_account_resource_id - self.sql_server_resource_id = sql_server_resource_id + 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): @@ -14167,59 +14750,21 @@ class OperationDisplay(_serialization.Model): "operation": {"readonly": True}, "description": {"readonly": True}, } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = 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"}, + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name = None - self.unit = None - self.change_value_absolute = None - self.change_value_relative = None + self.provider = None + self.resource = None + self.operation = None + self.description = None class OperationListResult(_serialization.Model): @@ -14470,6 +15015,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. @@ -15126,13 +15700,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 +15788,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 +16358,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 +16471,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 +16503,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 +16521,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 +16538,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 +17239,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 +17269,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 +17280,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 +17294,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 +17310,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 +17492,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 +17539,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 +17559,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 +17599,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 +17621,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 +18219,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 +18739,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 +18788,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 +19323,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 +19360,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 +19379,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 +19417,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 +19439,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 +19681,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 +19711,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 +19737,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 +19758,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 +19785,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 +19892,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 +20395,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 +21611,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 +21872,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 +21902,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..95dcecaf228f 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" @@ -149,7 +149,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" @@ -158,7 +158,7 @@ class AvailabilityZoneType(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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" @@ -216,6 +216,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 +403,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 +416,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): @@ -509,6 +524,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 +540,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 +599,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. @@ -647,6 +695,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.""" @@ -719,26 +774,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 +852,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 +880,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 +1007,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,7 +1030,7 @@ class ReplicationLinkType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDBY = "STANDBY" -class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class ReplicationModeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The replication mode of a distributed availability group. Parameter will be ignored during link creation. """ @@ -1028,6 +1079,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 +1141,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" @@ -1193,76 +1257,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 +1298,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 +1427,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..2ecdac5f7314 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,109 @@ # 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_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 +121,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 +168,105 @@ 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", "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 +275,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 +320,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..3cac03f865bb 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-02-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-02-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-02-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-02-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..845bf897ef36 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-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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..2afa6e6fb3f8 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-02-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-02-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..d3adc7357e63 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-02-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-02-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..0f59df53cb8a 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-02-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-02-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..1195b306ae0d 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-02-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-02-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-02-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..d6f3558fd507 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-02-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-02-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-02-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..d7fd8f10faf1 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-02-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-02-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..9b00d981f148 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-02-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-02-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-02-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..8131f7def7f4 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-02-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-02-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-02-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..834f1a2b470f 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-02-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-02-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..388ac382909e 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-02-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-02-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-02-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..3b5cda7d3a6f 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-02-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-02-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..a4631a22e5e7 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-02-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-02-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-02-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..798070a582bb 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-02-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-02-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..9a7303cebdd0 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-02-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-02-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-02-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..f5507c6523dc 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-02-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-02-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-02-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..df52a037b77e 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-02-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..d5edc79ba7c7 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-02-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-02-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-02-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-02-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..2e8d6635d884 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-02-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-02-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..55c1d348d1f6 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-02-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-02-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..b58572442f51 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-02-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-02-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..f30d4965d01a 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-02-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-02-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..399ec302488b 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-02-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..e250d6fe90ef 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-02-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-02-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-02-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..e6d77b7d16ac 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-02-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-02-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-02-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-02-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..3abf9a467eeb 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-02-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-02-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-02-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-02-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..81b59c1d4043 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,71 +39,6 @@ _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: @@ -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..8cb0f926db1b 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-02-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-02-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-02-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-02-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..517cc58a1a79 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-02-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-02-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-02-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-02-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-02-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-02-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( @@ -397,7 +450,7 @@ def _create_or_update_initial( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO], + parameters: Union[_models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, IO], **kwargs: Any ) -> Optional[_models.DistributedAvailabilityGroup]: error_map = { @@ -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) @@ -421,7 +474,7 @@ def _create_or_update_initial( if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") + _json = self._serialize.body(parameters, "DistributedAvailabilityGroupsCreateOrUpdateRequestBody") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -472,7 +525,7 @@ def begin_create_or_update( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: _models.DistributedAvailabilityGroup, + parameters: _models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, *, content_type: str = "application/json", **kwargs: Any @@ -487,7 +540,7 @@ def begin_create_or_update( :param distributed_availability_group_name: The distributed availability group name. Required. :type distributed_availability_group_name: str :param parameters: The distributed availability group info. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -550,7 +603,7 @@ def begin_create_or_update( resource_group_name: str, managed_instance_name: str, distributed_availability_group_name: str, - parameters: Union[_models.DistributedAvailabilityGroup, IO], + parameters: Union[_models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody, IO], **kwargs: Any ) -> LROPoller[_models.DistributedAvailabilityGroup]: """Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. @@ -563,8 +616,9 @@ def begin_create_or_update( :param distributed_availability_group_name: The distributed availability group name. Required. :type distributed_availability_group_name: str :param parameters: The distributed availability group info. Is either a - DistributedAvailabilityGroup type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroup or IO + DistributedAvailabilityGroupsCreateOrUpdateRequestBody type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.DistributedAvailabilityGroupsCreateOrUpdateRequestBody + or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -584,7 +638,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 +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", "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 +768,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 +828,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 +998,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 +1043,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..0a6002803cad 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-02-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-02-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..0c7718e361e7 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-02-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-02-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-02-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-02-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-02-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-02-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..585bc90da9fb 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-02-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-02-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-02-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-02-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..e8f229e37462 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-02-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-02-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..85460a101247 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-02-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-02-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-02-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..364ec1efc7cd 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-02-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-02-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-02-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..544766d07f3c 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..6f643d8c858a 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-02-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-02-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-02-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-02-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-02-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..5c17132431fb 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-02-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-02-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-02-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..5c955136e6db 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-02-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-02-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-02-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-02-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-02-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-02-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..0721814bbef4 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-02-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-02-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-02-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-02-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-02-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-02-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..bba84b2eac96 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-02-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-02-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-02-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-02-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..3aca1a6cc9d5 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-02-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-02-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-02-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-02-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-02-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..9da589ffb9ad 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-02-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-02-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-02-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-02-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..f48ef5015855 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-02-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-02-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-02-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-02-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-02-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-02-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/_job_step_executions_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_job_step_executions_operations.py index 0d964af025e4..b86a7d421f8e 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-02-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-02-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..169c8ef86234 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-02-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-02-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-02-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-02-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-02-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-02-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..74f89c100072 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-02-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-02-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-02-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..7eebbfa031f9 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-02-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-02-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-02-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-02-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..965fbf777644 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-02-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-02-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..ee6006bfa47b 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-02-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-02-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-02-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-02-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..0d00ece0eddc 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-02-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-02-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-02-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-02-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..bc0b6d464908 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-02-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-02-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-02-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-02-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-02-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_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-02-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}/copy", ) # pylint: disable=line-too-long path_format_arguments = { "locationName": _SERIALIZER.url("location_name", location_name, "str"), @@ -235,70 +280,71 @@ 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_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-02-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}/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 - 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_list_by_resource_group_location_request( + resource_group_name: str, location_name: str, - long_term_retention_server_name: str, subscription_id: str, *, only_latest_per_database: Optional[bool] = None, @@ -308,19 +354,17 @@ 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-05-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) 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}/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"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_name, "str" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -341,26 +385,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-02-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 +412,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-02-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 +463,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 +495,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-02-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -490,7 +538,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-02-01-preview")) # Construct URL _url = kwargs.pop( "template_url", @@ -517,27 +565,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_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-02-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}/copy", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -548,125 +595,79 @@ 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_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-02-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}/update", ) # 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"), + "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( - resource_group_name: str, - location_name: str, - long_term_retention_server_name: str, - subscription_id: str, - *, - only_latest_per_database: Optional[bool] = None, - database_state: Optional[Union[str, _models.DatabaseState]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) +class LongTermRetentionBackupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-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}/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"), - "longTermRetentionServerName": _SERIALIZER.url( - "long_term_retention_server_name", long_term_retention_server_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) - - -class LongTermRetentionBackupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.sql.SqlManagementClient`'s - :attr:`long_term_retention_backups` attribute. - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`long_term_retention_backups` attribute. + """ models = _models @@ -677,15 +678,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 +716,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, - location_name: str, - long_term_retention_server_name: str, + 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 +900,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 +1022,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,47 +1049,248 @@ 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 + ) -> 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 = 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_delete( + self, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a long term retention backup. + + :param location_name: The location of the database. 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 callable cls: A custom type or function that will be passed the direct response + :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._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, + 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_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" + } + + 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 + ) -> 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_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) + + _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_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" + } + + @overload + 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 + ) -> 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 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 @@ -1040,7 +1310,7 @@ def begin_update( """ @overload - def begin_update( + def begin_copy( self, location_name: str, long_term_retention_server_name: str, @@ -1051,7 +1321,7 @@ def begin_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -1061,7 +1331,7 @@ 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. Required. + :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". @@ -1082,16 +1352,16 @@ def begin_update( """ @distributed_trace - def begin_update( + 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.UpdateLongTermRetentionBackupParameters, IO], + parameters: Union[_models.CopyLongTermRetentionBackupParameters, IO], **kwargs: Any ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: - """Updates an existing long term retention backup. + """Copy an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -1101,9 +1371,9 @@ 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 + :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 @@ -1124,14 +1394,14 @@ 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-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._update_initial( + 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, @@ -1167,56 +1437,53 @@ 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_copy.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/copy" } - @distributed_trace - def get( + def _update_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], **kwargs: Any - ) -> _models.LongTermRetentionBackup: - """Gets a long term retention backup. + ) -> Optional[_models.LongTermRetentionBackupOperationResult]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) 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 - :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 {} + _headers = case_insensitive_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, "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, - template_url=self.get.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1230,85 +1497,118 @@ 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}" + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } - def _delete_initial( # pylint: disable=inconsistent-return-statements + @overload + 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 - ) -> 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 + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates 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 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: + """ - if cls: - return cls(pipeline_response, None, {}) + @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. - _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 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_delete( + 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 - ) -> LROPoller[None]: - """Deletes a long term retention backup. + ) -> LROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. :param location_name: The location of the database. Required. :type location_name: str @@ -1318,6 +1618,12 @@ def begin_delete( :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 @@ -1326,25 +1632,30 @@ 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 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[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, 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._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, @@ -1352,9 +1663,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("LongTermRetentionBackupOperationResult", 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,28 +1684,26 @@ 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_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } @distributed_trace - def list_by_database( + 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, 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. + """Lists the long term retention backups for a given location. + :param resource_group_name: The name of the resource group that contains the resource. You can + 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 @@ -1408,7 +1719,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 = { @@ -1422,15 +1733,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, ) @@ -1438,7 +1748,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" @@ -1468,22 +1789,29 @@ def get_next(next_link=None): return ItemPaged(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 ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. + """Lists the long term retention backups for a given server. + :param resource_group_name: The name of the resource group that contains the resource. You can + 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 @@ -1499,7 +1827,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 = { @@ -1513,13 +1841,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, ) @@ -1527,7 +1857,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" @@ -1557,25 +1898,32 @@ def get_next(next_link=None): return ItemPaged(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 ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. + """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 @@ -1591,7 +1939,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 = { @@ -1605,14 +1953,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, ) @@ -1620,7 +1970,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" @@ -1650,8 +2011,224 @@ def get_next(next_link=None): return ItemPaged(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" + } + + @distributed_trace + 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, + **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: + """ + 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_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.get_by_resource_group.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("LongTermRetentionBackup", 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}" + } + + 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", self._config.api_version)) + 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 = 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 + 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, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a long term retention backup. + + :param resource_group_name: The name of the resource group that contains the resource. You can + 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 + :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._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: 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_delete_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" } def _copy_by_resource_group_initial( @@ -1675,7 +2252,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) @@ -1868,7 +2445,7 @@ 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) @@ -1937,7 +2514,7 @@ 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) @@ -2130,7 +2707,7 @@ def begin_update_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) @@ -2177,513 +2754,3 @@ def get_long_running_output(pipeline_response): begin_update_by_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } - - @distributed_trace - 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, - **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: - """ - 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[_models.LongTermRetentionBackup] = kwargs.pop("cls", None) - - request = build_get_by_resource_group_request( - resource_group_name=resource_group_name, - location_name=location_name, - long_term_retention_server_name=long_term_retention_server_name, - long_term_retention_database_name=long_term_retention_database_name, - backup_name=backup_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get_by_resource_group.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("LongTermRetentionBackup", 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}" - } - - 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 = 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 - 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, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a long term retention backup. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :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", "2021-05-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_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: 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_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( - 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. - - :param resource_group_name: The name of the resource group that 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) - - 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 - - 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_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( - 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.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given location. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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", "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) - - list_by_resource_group_location.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups" - } - - @distributed_trace - 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 - ) -> Iterable["_models.LongTermRetentionBackup"]: - """Lists the long term retention backups for a given server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :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) - - 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_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: - 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_resource_group_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups" - } 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..c01e4e422dc5 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,39 @@ _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, **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-02-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") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -75,75 +79,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-02-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-02-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 +162,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-02-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 +206,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-02-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 +237,41 @@ 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, **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-02-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") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -276,79 +280,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-02-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-02-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 +367,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-02-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 +414,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-02-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 +465,216 @@ 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, + **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 + :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, + 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 +705,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 +758,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 +822,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 +865,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 +895,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 +909,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 +924,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,25 +965,26 @@ 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, **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 @@ -782,7 +1001,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 +1015,14 @@ 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, 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 +1030,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 +1071,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 +1113,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 +1127,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 +1144,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 +1185,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 +1228,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 +1288,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 +1362,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 +1405,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 +1440,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 +1470,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 +1514,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..5f1f010e1a5a 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-02-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-02-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-02-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) @@ -328,7 +424,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -370,7 +466,7 @@ def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -410,7 +506,7 @@ def begin_create_or_update( parameters: Union[_models.LongTermRetentionPolicy, IO], **kwargs: Any ) -> LROPoller[_models.LongTermRetentionPolicy]: - """Sets a database's long term retention policy. + """Set or update 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. @@ -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..60491543bf59 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-02-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..7d283b912899 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-02-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-02-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..e241da4b0fe1 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-02-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-02-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-02-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-02-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..7b95b81eeeda 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-02-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-02-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-02-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..4c7d537d3181 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-02-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-02-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-02-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..5783a3a6fc90 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-02-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-02-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..6f677fc7d135 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-02-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-02-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..ece168383dd5 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-02-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..303df2c10281 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-02-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..0044638648c8 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-02-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-02-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..eeacc21df9ef 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-02-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-02-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-02-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..f4dd29e9810c 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-02-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..9af19faced06 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..4332d6974dc2 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-02-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-02-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..a9a8e083819b 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-02-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-02-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-02-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..0c761e2fc046 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-02-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-02-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-02-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..188fb1b402ce 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-02-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-02-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-02-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-02-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..023a5435efa1 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-02-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-02-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-02-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-02-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..e15b4a2f5edb 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..5d8a3573a21c 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-02-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-02-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-02-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-02-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..2e198227e794 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-02-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-02-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-02-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..6a448b7ca09b 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-02-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-02-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-02-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-02-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..394c9660623b 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-02-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-02-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-02-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..750b0a3a24eb 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-02-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-02-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-02-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-02-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..c636ef9765d8 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-02-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-02-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-02-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-02-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..14179fea8ed0 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-02-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-02-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-02-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-02-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..d9a90577f3b0 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-02-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-02-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-02-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..0764300b13bd 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-02-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-02-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-02-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-02-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..1ca504d96520 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-02-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-02-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..81a1f82c7d09 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-02-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..a9fb90edfca2 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-02-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-02-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-02-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-02-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..dea334a1f45c 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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,138 @@ 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 + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("RefreshExternalGovernanceStatusOperationResultMI", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + 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 +1776,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 +1812,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 +1837,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 +1864,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 +1878,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 +1900,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 +1936,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 +1961,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 +2036,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 +2070,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..74153e0de946 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-02-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-02-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-02-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-02-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..1599524167f2 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-02-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-02-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-02-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-02-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..54d6340d3673 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-02-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-02-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-02-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-02-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-02-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..6a59039024dc 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-02-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-02-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-02-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/_server_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py similarity index 50% 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/_network_security_perimeter_configurations_operations.py index 4e722959c0ec..48122ba082c2 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/_network_security_perimeter_configurations_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,51 +38,24 @@ _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 -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", - ) # 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - - -def build_get_request( - resource_group_name: str, server_name: str, communication_link_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", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-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}/networkSecurityPerimeterConfigurations", ) # 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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -96,26 +69,25 @@ 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, communication_link_name: str, subscription_id: str, **kwargs: Any +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", "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-02-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}/networkSecurityPerimeterConfigurations/{nspConfigName}", ) # 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"), + "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 @@ -124,31 +96,30 @@ 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_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", "2014-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-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", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile", ) # 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"), + "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 @@ -159,17 +130,17 @@ def build_list_by_server_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) -class ServerCommunicationLinksOperations: +class NetworkSecurityPerimeterConfigurationsOperations: """ .. 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:`network_security_perimeter_configurations` attribute. """ models = _models @@ -182,23 +153,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_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 - :param communication_link_name: The name of the server communication link. Required. - :type communication_link_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 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, @@ -207,59 +184,83 @@ 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: + + 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", "2014-04-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + 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 - 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) + 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) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def get_next(next_link=None): + request = prepare_request(next_link) - response = pipeline_response.http_response + _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 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 + + return ItemPaged(get_next, extract_data) - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}" + 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, communication_link_name: str, **kwargs: Any - ) -> _models.ServerCommunicationLink: - """Returns a server communication link. + 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 communication_link_name: The name of the server communication link. Required. - :type communication_link_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: ServerCommunicationLink or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.ServerCommunicationLink + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -273,13 +274,13 @@ 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.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + nsp_config_name=nsp_config_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], @@ -300,7 +301,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("NetworkSecurityPerimeterConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -308,17 +309,12 @@ 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}/networkSecurityPerimeterConfigurations/{nspConfigName}" } - def _create_or_update_initial( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], - **kwargs: Any - ) -> Optional[_models.ServerCommunicationLink]: + 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, @@ -327,31 +323,19 @@ 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", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerCommunicationLink]] = 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, "ServerCommunicationLink") + 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_create_or_update_request( + request = build_reconcile_request( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, + nsp_config_name=nsp_config_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"], + template_url=self._reconcile_initial.metadata["url"], headers=_headers, params=_params, ) @@ -365,125 +349,36 @@ 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, 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 == 201: - deserialized = self._deserialize("ServerCommunicationLink", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", 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}/communicationLinks/{communicationLinkName}" + _reconcile_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" } - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: _models.ServerCommunicationLink, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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 - :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 ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: 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 ServerCommunicationLink or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - server_name: str, - communication_link_name: str, - parameters: Union[_models.ServerCommunicationLink, IO], - **kwargs: Any - ) -> LROPoller[_models.ServerCommunicationLink]: - """Creates a server communication link. + 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 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 - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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 @@ -492,28 +387,26 @@ 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 - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.ServerCommunicationLink] + :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 = 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", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - 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.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._create_or_update_initial( + raw_result = self._reconcile_initial( resource_group_name=resource_group_name, server_name=server_name, - communication_link_name=communication_link_name, - parameters=parameters, + nsp_config_name=nsp_config_name, api_version=api_version, - content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -522,13 +415,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("NetworkSecurityPerimeterConfiguration", 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: @@ -542,87 +437,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}/communicationLinks/{communicationLinkName}" - } - - @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. - - :param resource_group_name: The name of the resource group that 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.paging.ItemPaged[~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) - - 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("ServerCommunicationLinkListResult", 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}/communicationLinks" + 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..3723387cf6d5 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-02-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..95b252db60b2 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-02-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-02-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-02-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-02-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..f9bc3e81511b 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-02-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-02-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-02-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-02-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..0f3da009e8c7 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-02-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-02-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..eae020cf0dea 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-02-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..72a5c91ad9df 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-02-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-02-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..89e20cc88993 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-02-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-02-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..876b3bd1a48b 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-02-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-02-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-02-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-02-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-02-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-02-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..c98720a1329a 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-02-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-02-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..d7425d742e01 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-02-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-02-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..6cf50aed344c 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-02-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-02-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-02-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-02-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..5425362dd9c6 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..5fd67ce97940 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-02-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-02-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-02-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..7c1dd3b6f67b 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-02-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-02-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-02-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..a6364c826f7a 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-02-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-02-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..60ad5765cdf4 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-02-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-02-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-02-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-02-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..ba90e00d6d4a 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-02-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-02-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-02-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-02-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..219861f79738 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-02-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-02-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-02-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..9520180e9286 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-02-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-02-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-02-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..73623269dbc7 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-02-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-02-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-02-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..9dffad1719ec 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-02-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-02-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-02-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..8cd3bbe88cbc 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-02-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-02-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-02-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-02-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-02-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..aba1964defc0 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-02-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-02-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-02-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-02-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..e9369958c778 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-02-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..c682dd3b731b 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-02-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-02-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-02-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..c42fd24fb719 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-02-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-02-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-02-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-02-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..63dd7fdead73 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-02-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-02-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-02-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-02-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-02-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..6373ab4d27f5 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-02-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..eb017dce3583 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-02-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-02-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-02-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-02-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..ab7fcc89c5cd 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..b7487e9ef09c 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-02-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-02-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..c60f9d39de85 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-02-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-02-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..b054727868db 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-02-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..22a90371f5f9 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-02-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..ae53e12bb3c5 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-02-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-02-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-02-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..bf6ef21b347b 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-02-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..6a17522491f0 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-02-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-02-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..3b8e6799e039 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-02-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-02-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..05b4d35eaf54 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-02-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..e9d8bb7ac23d 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-02-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-02-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-02-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..89894d466f3a 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-02-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-02-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-02-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-02-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..d86d4bf7fe79 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-02-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-02-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..6354f3b39792 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-02-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..4a718433d36a 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-02-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-02-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-02-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-02-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-02-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-02-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..062707d5a6df 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..50798d067b3f 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-02-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-02-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-02-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-02-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-02-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-02-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-02-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..cf89d2c835af 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-02-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..4300ae80f2bd 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-02-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-02-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..d76e7b9722ae 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-02-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-02-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-02-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..e46a07e9da1f 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-02-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..913bb8dca300 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-02-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-02-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-02-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-02-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-02-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-02-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..50b693e36e72 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-02-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-02-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-02-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-02-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..fab59594bf20 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-02-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-02-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-02-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-02-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..12775b014598 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-02-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-02-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-02-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-02-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..eb9e9ecc81cf 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-02-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..527d37a87900 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-02-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..c6a4a44f046e 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-02-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..6a52ff60959c 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-02-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..b7101633b1ba 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-02-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..f74c777ccbe9 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-02-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..d9ac1be7eeb1 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-02-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..6e6ad962227b 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-02-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..5163c1e13390 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-02-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..61180c7a2efa 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-02-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..8b1592dfecc3 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-02-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..f4b24e084fa9 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-02-01-preview/examples/CancelManagedInstanceOperation.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..934b55cd6cdd 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-02-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..51cce51f1b99 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-02-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..ae44591cca94 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-02-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..fb03a16a68ae 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-02-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..9dda605ade71 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-02-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..fbb2315377dd 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-02-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..9cf8a3e91721 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-02-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..7a94b3fd8481 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-02-01-preview/examples/ColumnsListByDatabaseMin.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..c980d88d55c2 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-02-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..43e6a64380ef 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-02-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..8f11d278ec5d 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-02-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..5b10d9e6a0b2 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-02-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..63e2151ffcfc 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 @@ -46,6 +46,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-02-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..3844575b85cd 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-02-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..8ac2802af8dc 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-02-01-preview/examples/CreateOrUpdateJobAgent.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..ef0fd1a3a162 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-02-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..6a6c244aa95c 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-02-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..8d72db5f0d88 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-02-01-preview/examples/CreateOrUpdateJobMax.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..bb1b57d5b1a0 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-02-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..93b7773473f6 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 @@ -46,6 +46,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-02-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..3fdf3ce20da9 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-02-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..bc9ea77de42f 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-02-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..8df5102a71a4 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-02-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..edb9b811f119 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-02-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..43f950275d20 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-02-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..1dcac366fc18 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-02-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..574fbe6aff89 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-02-01-preview/examples/CreateOrUpdateWorkloadGroupMin.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..cb8020cae023 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-02-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..f2e406669e73 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-02-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..99b33ca52540 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-02-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..05cefb5f9710 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-02-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..8cf880baff5e 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-02-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..3392baf25c55 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-02-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..447dc721c497 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-02-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..4dcf18d9d4dd 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-02-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..9fc6fc0df2e8 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-02-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..87075be6fad5 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-02-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..ad1cc59765b6 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-02-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..277c11d9046d 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-02-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..a14760a022a4 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-02-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..fcca1be0d021 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-02-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..5bd807384362 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-02-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..a4a3a0420520 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-02-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..6783345917bd 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-02-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..3925a538dfbc 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-02-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..43a828b44c3e 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-02-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..f73b3b6c2cbf 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-02-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..46e89acc1e79 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-02-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..86720650ce1b 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-02-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..c2126da84d5c 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-02-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..f87126747025 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-02-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..7d935fb074cf 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-02-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..105ec7c5eda5 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-02-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..f4d4e68cebaa 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-02-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..ad40fcabf4ae 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-02-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..16bc48e110d1 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-02-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..f4df885e4e4d 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-02-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..b7ad57a44636 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-02-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..0ab5b525e744 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-02-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..ae985615e8b6 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-02-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..a201ea2cd3b0 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-02-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..bd7dbe7127f6 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-02-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..3f2883fd06d7 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-02-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..90eeb4b2dbcb 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-02-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..c985aacf4d15 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-02-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..9c77ced3cce4 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-02-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..6c42898e5ffd 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-02-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..69495194b91a 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-02-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..3d19579fd029 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-02-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..d92da90991df 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-02-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..8cc8b2d030e3 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-02-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..3a9630ec126e 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-02-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..c6289323d6d4 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-02-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..730226858dcf 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-02-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..9a91b8d92b3f 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-02-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..58820848efb5 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-02-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..9d6dbdd4002a 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-02-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..2d2f9f6c095c 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-02-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..8a7af0e66e57 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-02-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..306fd02407ec 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-02-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..26a7b189f4e4 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-02-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..81a83bf1ec6e 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-02-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..fed9b4e3d9ec 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-02-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..8dc935506034 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-02-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..3544081a8201 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-02-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..2fdf96244a22 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-02-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..183519877cfb 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-02-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..fae4cf93a78f 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-02-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..133a9ed79de3 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-02-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..5b636ff29918 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-02-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..9f8d32c426e7 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-02-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..b21d4ea7c203 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-02-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..bf5e35ffea2d 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-02-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..cf09a2c8f10a 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-02-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..e1a5687ad792 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-02-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..9c65fb3e4706 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-02-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..32a636f8b0ef 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-02-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..1a6cba33c0f2 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-02-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..14c989972a84 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-02-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..8c579274b724 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-02-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..6e8b475e2274 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-02-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.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..fe4dd6e178d5 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-02-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..c7c87f6de594 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-02-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..f2247da72141 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-02-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..42ce7ce7b4bb 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-02-01-preview/examples/DeleteJobCredential.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..46c837b1bfd4 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-02-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..5cd3d9d79339 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-02-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..a9970600bee3 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-02-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..036ac8020759 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-02-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..6e5e20a3e9a4 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-02-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..6396b45e8ed0 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-02-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..320dddf4c732 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-02-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..82a7fd191a88 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-02-01-preview/examples/DeletedServerRecover.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.py index 8d1eca0c6e45..dbb720fe2b60 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.py @@ -45,6 +45,6 @@ def main(): 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-02-01-preview/examples/DistributedAvailabilityGroupsCreate.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..9369b3ed95ba 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-02-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..4ae3814aef55 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-02-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..8f87d9980fe0 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-02-01-preview/examples/DistributedAvailabilityGroupsListByInstance.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/distributed_availability_groups_set_role.py similarity index 74% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py index 5ad837baa643..a990d819f577 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python elastic_pool_metrics_definitions_list.py + 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, @@ -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", - ) - for item in response: - print(item) + 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/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-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..c842822dff83 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-02-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..b8ba9ce3d4d5 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-02-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..7de57469ffb8 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-02-01-preview/examples/ElasticPoolCreateOrUpdateMin.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..54b3f4743e8a 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-02-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..576aa8a37fa3 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-02-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..65f8501250ad 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-02-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..a3ef50af646a 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-02-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..f65fe4ecf89d 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-02-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..6277ccd29bdb 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-02-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..c8acb1dd3e43 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-02-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..f8e7515e9e1e 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-02-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..6e178e0043a4 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-02-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..788671648e13 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-02-01-preview/examples/ElasticPoolUpdateResetMaintenanceConfiguration.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..b81cc3a75fb1 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-02-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..981f21e5498c 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-02-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..d80d0010d04c 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-02-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..eed8e1f13ff0 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-02-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..1aef2c62fa16 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-02-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..9e46ebd16d0e 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-02-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..8012af26a10f 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-02-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..37302525b5d3 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-02-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..e15f4a2b7b3f 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-02-01-preview/examples/EndpointCertificatesListByInstance.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..5b97bce00cff --- /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-02-01-preview/examples/ExportDatabaseUsingDatabaseExtensions.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..1cce96978daf 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-02-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..fc25f352e412 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-02-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..c98a71fc6952 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-02-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..f55e009e4427 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-02-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..b5aa421bba50 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-02-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..e3dce1d5ddc0 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-02-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..38a9211e029f 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-02-01-preview/examples/ExtendedServerBlobAuditingGet.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..1cc61e06614b 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-02-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..e949599a3b05 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-02-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..2219447041d9 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-02-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..1e7f1e5afd11 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-02-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..876bbf789806 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-02-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..5f808674eb5b 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-02-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..504d5806a953 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-02-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..325fce6060f3 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-02-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..63c25981baf1 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-02-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..b3e53689d00d 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-02-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..23aceef1f226 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-02-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..eb569615ee70 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-02-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..f094513fb66b 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-02-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..2f6ed06066e0 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-02-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..f97cafadacc9 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-02-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..ad28f2334555 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-02-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..6e091d7a13ba 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-02-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..111255b519f6 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-02-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..909f4e3f5546 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-02-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..4c7ad65c7270 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-02-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..939429e069e8 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-02-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..b3567ed0fc7f 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-02-01-preview/examples/GetDatabaseUsages.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..ceedb51c7475 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-02-01-preview/examples/GetElasticPoolWithAvailabilityZone.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..18c15f7fd594 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-02-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..724693753c11 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-02-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..4722d6453a44 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-02-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..a79ee74f6670 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-02-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..0fd2d0ea2856 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-02-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..240675a05051 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-02-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..62e421fe43d4 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-02-01-preview/examples/GetJobExecutionTarget.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..61133b3c1f45 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-02-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..d3591fcf5107 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-02-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..0e6f1d8f4162 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-02-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..20ef8f18f142 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-02-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..295b406400c7 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-02-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..1edf529b54d1 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-02-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..e5e3d364fb8a 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-02-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..65a63ce66e7b 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-02-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..fe5760ce4a09 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-02-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..cdcc0feb6ce0 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-02-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..86c84dc07d04 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-02-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..f017867e18dc 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-02-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..702e7a275b9e 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-02-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..78ad7a0be10a 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-02-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..8c64e6f72fc3 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-02-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..974383fd443f 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-02-01-preview/examples/GetShortTermRetentionPolicy.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..0bc02bec318e 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-02-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..3180d6fe6e28 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-02-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..2a9522f71106 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-02-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..66c582509ef0 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-02-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..9361ef6cd1dc 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-02-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..be900b5a8fa4 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-02-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..4c6c301a6318 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-02-01-preview/examples/HyperscaleElasticPoolUpdateSetHighAvailabilityReplicaCount.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..248aabccd71a --- /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-02-01-preview/examples/ImportDatabaseUsingDatabaseExtensions.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..b55e49889a48 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-02-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..8c72f0ee4bbc 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-02-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..ddc0d423e33e 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-02-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..165d921fcdf8 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-02-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..50b1669fa722 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-02-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..2761cc8c4095 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-02-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..9a9201436270 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-02-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..615f654ed86f 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-02-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..ff5f0cf13c51 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-02-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..1a6c10d5776f 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-02-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..12ee2850adbc 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-02-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..65ce30b8e900 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-02-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..23238011ab53 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-02-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..33b75ee6d86d 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-02-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..a284ae0dd9d8 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-02-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..5da8ac2dfd3c 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-02-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..ea053f779f90 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-02-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..2f947ec713d8 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-02-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..6de3f71bc25b 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-02-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..adf5ab27b1cb 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-02-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..8236e3496e37 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-02-01-preview/examples/ListDatabaseOperations.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..4185990c9083 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-02-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..2e215bc83cb5 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-02-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..3cf7e60052b2 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-02-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..24e420c0bd32 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-02-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..cecef9e5a4ef 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-02-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..edbb47a4b37a 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-02-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..43a7809dc6dd 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-02-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..b34aded1bd29 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-02-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..5a67744f0a8c 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-02-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..572615fcd83e 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-02-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..8220f77558f6 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-02-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..ba637b3df74f 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-02-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..a37e2e60b58b 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-02-01-preview/examples/ListJobExecutionsByJob.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..96eee7ac3c04 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-02-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..f9804cbd05ec 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-02-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..028917a22937 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-02-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..7ea6bbb1a657 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-02-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..36b9a1d80dd4 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-02-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..de5d3074cdaa 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-02-01-preview/examples/ListManagedInstanceOperations.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_operations.py similarity index 81% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py index 17758295e5eb..bc6f98b941f0 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_operations.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_list.py + 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, @@ -26,17 +26,14 @@ def main(): client = SqlManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", + subscription_id="SUBSCRIPTION_ID", ) - response = client.service_objectives.list_by_server( - resource_group_name="group1", - server_name="sqlcrudtest", - ) + response = client.operations.list() 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-02-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..9561bc6df633 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-02-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..900ae7156cf4 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-02-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..8de7926d7ebd 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-02-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..4dbd22cca5a7 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-02-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..c52a77afdd4d 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-02-01-preview/examples/ListShortTermRetentionPoliciesByDatabase.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..1a3e5ff5b63e 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-02-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..d15a15d4872d 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-02-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..765e1f7287ed 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 @@ -37,6 +37,6 @@ def main(): ).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-02-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..437ab62d8356 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 @@ -38,6 +38,6 @@ def main(): 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-02-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..b9fd8f08c354 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-02-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..763c0e62bc01 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-02-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..87fd5e5c262d 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-02-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..1218de496737 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-02-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..48baa2452484 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 @@ -36,6 +36,7 @@ def main(): policy_name="default", parameters={ "properties": { + "makeBackupsImmutable": True, "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/LongTermRetentionPolicyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-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..2a02bc2770e4 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-02-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..f75976a007ec 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-02-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..485a64a85971 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-02-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..91a26748ccbc 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-02-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..6b5ab3cca2a2 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-02-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..280f354dc0d2 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-02-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..97dc4e78af24 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-02-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..6a02bc4bc9ee 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-02-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..0d76122d7230 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-02-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..fd4557ce25e7 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-02-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..1f0896375b63 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-02-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..e8e0d4d18a26 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-02-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..4bd7e9672987 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-02-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..20ffaa452188 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-02-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..f365be74d42a 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-02-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..6106105dfa94 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-02-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..1966280a4673 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-02-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..ea23e1ba134d 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-02-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..82dffd93f986 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-02-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..4398b902091f 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-02-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..719431007ad7 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-02-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..150c5c69c8fc 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-02-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..ab8ed46eb0f2 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-02-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..b4b28f394fab 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-02-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..3ea92d0a8dfd 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-02-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..3b89953175bc 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-02-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..a4064678c575 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-02-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..8191855a679c 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-02-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..cd7e6605f416 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-02-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..79cbe2a66251 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-02-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..ff0521ed570f 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-02-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..0ab048830b3b 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-02-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..b9837882fba1 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-02-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..c20762028d9c 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-02-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..ee2849c9fbdc 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-02-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..b6a34a392318 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-02-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..2f8f21defd30 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-02-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..ac018f9f58e4 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-02-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..135ab5b919c9 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-02-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..7072ca7b1243 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-02-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..50e133d5f895 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-02-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..113e29210c0a 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-02-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..3d327f6c374c 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-02-01-preview/examples/ManagedDatabaseSensitivityLabelsCurrentUpdate.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_database_sensitivity_labels_list_by_database.py similarity index 78% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py index 302e9555e80d..ad98b071583f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_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_activity_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_pool_activities.list_by_elastic_pool( - resource_group_name="sqlcrudtest-4291", - server_name="sqlcrudtest-6574", - elastic_pool_name="8749", + 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-legacy/examples/ElasticPoolActivityList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-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..16879a1f70b9 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-02-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..35bf8379a74f 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-02-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..0c1dc2078f8b 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-02-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..b3a7d26875ea 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-02-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..d9a5cb59c0d4 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-02-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..bbaee969c9ee 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-02-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..0e2166e21bfe 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-02-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..af2639aaf12c 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-02-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..006a53aaaae6 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-02-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..f2fe2fc43fce 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-02-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..7b91fc6ba745 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-02-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..3d3dd582ae38 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-02-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..7cf35cea18d4 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-02-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..471c7a210221 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-02-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..cc18d527a9b9 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-02-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..f7d5025a2771 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-02-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..2a812a9e7a87 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-02-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..17a705637c69 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-02-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..88b9a3a8063e 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-02-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..02175aaf5426 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-02-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..3484a8b53129 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-02-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..d4f0c470d864 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-02-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..06c3a1d9583c 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-02-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..72680992c757 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-02-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..16fe7ca4cbf1 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-02-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..b52992469e34 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-02-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..d498c57dc66e 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-02-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..0040c047dc79 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-02-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..43c0b3334d8e 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-02-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..ddb1b0c3aae7 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-02-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..7d4e322499d8 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-02-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..376c8b01048a 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-02-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..0637d721b00f 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-02-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..ae677bb211e4 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-02-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..b431bfb165db 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 @@ -46,6 +46,7 @@ def main(): }, "collation": "SQL_Latin1_General_CP1_CI_AS", "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 +67,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-02-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..85a289369c2a 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 @@ -48,6 +48,6 @@ def main(): 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-02-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..004c5009c94c 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-02-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..224582ba9db7 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-02-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..42476a71d169 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-02-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..15d8c98e4a83 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-02-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..35c5132de59e 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-02-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..99d9b8e0e70e 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-02-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..241666a33307 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-02-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..3d7dccbbbb32 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-02-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..99f29ae74814 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-02-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..d59adf6d0f92 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-02-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..58b905637c01 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-02-01-preview/examples/ManagedInstanceGet.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..71afc0fe8bef 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-02-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..30760a5b1e3a 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-02-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..11b0b81fabc6 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-02-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..56ae478dd34e 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-02-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..eca460214faa 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-02-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..1ac0230643f1 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-02-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..658f4be9bca1 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-02-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..0d8f2eece9db 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-02-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..c95a6d1d3299 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-02-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..3991a923c275 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-02-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..79597f3c219e 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-02-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..260ec91be142 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 @@ -37,6 +37,6 @@ def main(): ).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-02-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..52cdc9f6e68a 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 @@ -38,6 +38,6 @@ def main(): 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-02-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..75115a4f684c 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-02-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..0dec09617ee8 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-02-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..59580d37a8a7 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-02-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByLocation.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..049d14a86f7a 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 @@ -46,6 +46,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-02-01-preview/examples/ManagedInstanceLongTermRetentionPolicyCreateOrUpdate.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/managed_instance_long_term_retention_policy_delete.py similarity index 75% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py index 73e1c51aa36e..14537be360ce 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_get.py + 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, @@ -29,14 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.service_objectives.get( - resource_group_name="group1", - server_name="sqlcrudtest", - service_objective_name="29dd7459-4a7c-4e56-be22-f0adda49440d", - ) + 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/stable/2014-04-01/examples/ServiceObjectiveGet.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-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..8875538eb722 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-02-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..8c178fcdecfc 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-02-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..ec1cd565dabe 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-02-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..d3df08fe2e44 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-02-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..3416813e5d99 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-02-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..7b162ecd4eaa 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-02-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..4d7fc7b417ce 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-02-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..3819547a1698 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-02-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..87dd9368f1f6 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-02-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..148ce60ef13e 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-02-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..2b4ff21b15da 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-02-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..ff403a517d9d 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-02-01-preview/examples/ManagedInstanceQueryStatisticsListMin.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..e77a062a8e59 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-02-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..c7fa1aa00e9b 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-02-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..74e949bc70f3 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-02-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..415a56b6cf1c 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-02-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..eb3b46df8919 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-02-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..2e656535e29e 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-02-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..4d0829f9e63c 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-02-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..6bd53d192908 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( @@ -37,8 +37,9 @@ def main(): "administratorLogin": "dummylogin", "administratorLoginPassword": "PLACEHOLDER", "collation": "SQL_Latin1_General_CP1_CI_AS", + "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, @@ -53,6 +54,6 @@ def main(): 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-02-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..90576df17128 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-02-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..fe5451cee1c5 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-02-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..19b6122d50d4 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-02-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..cd67868b1c62 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-02-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..08f8da18c831 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-02-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..4529ae29b018 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-02-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..9728ab7cf135 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-02-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..bb95cc62b66b 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-02-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..6330edafdc80 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-02-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..d191b04cec61 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-02-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..0c52e24fb251 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-02-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..00e210e2355b 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-02-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..99f9eeed0ef2 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-02-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..d9f251605d0d 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-02-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..adc8c20b4c3f 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-02-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..432e394b8898 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-02-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..368b921032da 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-02-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..da11c0237ac8 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-02-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..1778aed51cad 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-02-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..990cea1ba75c 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-02-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..05025005e017 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-02-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..4bc8aacbbdfe 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-02-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..9e1166ad1e4e --- /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-02-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..70ead4a1d567 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-02-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..e13365e6dd3b 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-02-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..6a4c88253737 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-02-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..0b4f945db565 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-02-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..0d94caf87428 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-02-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..e4931b8e4743 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-02-01-preview/examples/OutboundFirewallRuleList.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..74dfc9b874d6 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-02-01-preview/examples/PatchInstancePool.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..98cf0b396617 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-02-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..7b1f4cdd8d99 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-02-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..1dd4c8d45d71 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-02-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..986b52e1c82b 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-02-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..57b71c9b7599 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-02-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..cc31f3a5a1b2 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-02-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..d064bfb422ef 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-02-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..d830bba57b8f 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-02-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..bda12ca2ad3c 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-02-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..cf8eb809a9e1 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-02-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..05e8896c2c29 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-02-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..8c1020d5f6c5 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-02-01-preview/examples/RefreshExternalGovernanceStatus.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/refresh_external_governance_status_mi.py similarity index 82% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py rename to sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status_mi.py index 072fa1091a30..ca685d5a42a9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status_mi.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python server_communication_link_delete.py + python refresh_external_governance_status_mi.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( + response = client.managed_instances.begin_refresh_status( resource_group_name="sqlcrudtest-7398", - server_name="sqlcrudtest-4645", - communication_link_name="link1", - ) + managed_instance_name="sqlcrudtest-4645", + ).result() + 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-02-01-preview/examples/RefreshExternalGovernanceStatusMI.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..26ea40701fd7 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-02-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..ff8d2a75c56f 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-02-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..044a379bd552 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-02-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..261cba367e57 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-02-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..1a92ed094404 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-02-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..c29a66d33290 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-02-01-preview/examples/ReplicationLinkListByServer.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..44d80b74c1b7 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-02-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..9b0c18f57f02 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 @@ -38,6 +38,6 @@ def main(): ).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-02-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..9817cc104d48 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 @@ -39,6 +39,6 @@ def main(): 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-02-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..21006c95840c 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-02-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..ef480cbf8234 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-02-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..fb2f2bd7709d 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-02-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..6106e37dab6f 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-02-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..d18809dcff64 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", ).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-02-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..31fffccb82e1 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 @@ -39,6 +39,6 @@ def main(): 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-02-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..0045ec7300af 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-02-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..8b1e9f97f0ae 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-02-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..c848f56070a4 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-02-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByLocation.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..688465279fb4 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-02-01-preview/examples/RestorableDroppedManagedDatabaseListByManagedInstance.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..87a67850d978 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-02-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..7c67f30697a5 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-02-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..a32182fd8ca2 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-02-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..7acf58cc6f99 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-02-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..f74cb0c4c06a 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-02-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..da849b425f16 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-02-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..3f66338cf6d0 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-02-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..5a38ab57f2a7 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-02-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..885ca09d68ee 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-02-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..9a19a7b9b51d 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-02-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..6e503fa0d67b 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-02-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..c03701947ef5 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-02-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..59e7600e6a4c 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-02-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..f97d89079729 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-02-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..bc5e0dc2725c 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-02-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..81134aa59ab1 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-02-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..bfc0d7c762a2 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-02-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..d61645fa5f67 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-02-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..e5bed81f9298 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-02-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..ae1c1d994a95 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-02-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..3f7802e1a56b 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-02-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..e51a708c9704 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-02-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..bf03c3b1896e 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-02-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..110578c96852 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-02-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..caa9c755d164 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-02-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..4ac2c7e160cf 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-02-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..7273eef43aa3 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-02-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..e8e40826a111 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-02-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..74c4317b22a5 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-02-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..55a0e4e4e69d 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-02-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..9b52289e99e6 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-02-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..54f95cb26ec9 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-02-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..3d569ed6d3c0 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-02-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..35395edb8794 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-02-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..f7de57dab66f 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-02-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..49f303b67bfc 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-02-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..130c9f390399 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-02-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..2854e1f22d07 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-02-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..3cb24b265367 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-02-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..8cd7d5c098c3 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-02-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..67c86008746c 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-02-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..b9daada628de 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-02-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..6ba4cdf188ea 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-02-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..d7ac5a5290d9 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-02-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..69c274535e8f 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-02-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..8c7e0dfcf983 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-02-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..75c72c2b4df0 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-02-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..1e3088530b51 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-02-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..aa1200535fb9 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-02-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..ed877f414c2a 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-02-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..d818182b6593 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-02-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..f7c0cdb06a08 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-02-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..e59cd95bf5a8 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-02-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..4719a8ccbf06 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-02-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..dbe15f935dce 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-02-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..17d286733ca1 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-02-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..14f471e35258 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-02-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..d4c1fdcd2280 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-02-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..ba53434f07e2 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-02-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..60376d240b81 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-02-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..a4a22ce4a9df 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-02-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..96c3fdd64a6f 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-02-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..de027ca9459c 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-02-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..f4fa770dd120 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-02-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..45a8d7c317b5 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-02-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..f892258b66ee 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-02-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..37902b954319 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-02-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..b199d26ae270 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-02-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..00baaa4298c2 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-02-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..ae064f89b467 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-02-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..03bfdb6df644 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-02-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..28e7130c6e13 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-02-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..d35b75d2be6a 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-02-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..fcd9431951de 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-02-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..dc849bd461b9 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-02-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..aefd9b948493 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-02-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..3cfa2f702e0e 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-02-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..034ec1a2f8ae 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-02-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..36d9d73bef38 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-02-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..70d6b4ec54a1 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-02-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..1e34bd53afa1 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-02-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..f1ab56ce8535 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-02-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..325c13659091 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-02-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..0e5ee749a464 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-02-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..4b87bd6aa6cc 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-02-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..b50947a2e4ac 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-02-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..5a0530e8d555 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-02-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..469ce66d0c7a 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-02-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..4a251433411a 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-02-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..dc2c197f5c41 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-02-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..808a1b1af0e4 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-02-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..90059199735d 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-02-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..f5a286446124 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-02-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..a5a736e2365a 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-02-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..bb7ed5c6ae7b 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-02-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..4b3ee74a123d 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-02-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..80e55510db46 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-02-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..e07b2f4c603d 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-02-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..c9be2b3fa1b2 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-02-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..12360635f22e 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-02-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..358cbde69e2b 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-02-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..be14d03e60e3 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-02-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..59676c3bf3a8 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-02-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..faab69aae8a0 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-02-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..8aed7dfdd984 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-02-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..fb74a81d00d6 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-02-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..1f3042cbd7a2 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-02-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..c4b61f0fa2db 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-02-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..87a45f6cf760 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-02-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..dd1497fa2212 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-02-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..92369c3d9903 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-02-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..dd4e8c1660cb 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-02-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..22b0a01a2569 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-02-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..cff6f7a77da4 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-02-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..8face611dac7 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-02-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..326b395887c0 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-02-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..36f1b370c9d0 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-02-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..e1819c606bf3 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-02-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..099bfe88dbb8 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-02-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..52cd32259aaa 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-02-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..30826d054ee4 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-02-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..d9b5ff65743e 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-02-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..3eb822ade082 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-02-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..7a0bb809f1d1 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-02-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..04559641af1a 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-02-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..a4638deea3ca 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-02-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..13f4d39d69d1 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-02-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..659753faa677 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-02-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..6a1443a66e6e 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-02-01-preview/examples/TransparentDataEncryptionUpdate.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..031bb136cd18 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-02-01-preview/examples/UpdateJobAgent.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..fb39b16d4a62 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-02-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..9c622264a464 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-02-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..a417ae1049f8 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-02-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..883dfdf128e4 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-02-01-preview/examples/UpdateVirtualClusterDnsServers.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..d8e5b3329091 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-02-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..d0e828812616 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-02-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..af51bfcb1c03 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-02-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..d811212d2f6e 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-02-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..a38117e23bd9 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-02-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..0a6f75e7db6f 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-02-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..4e4edad3b778 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-02-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..cc641cd58b56 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-02-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..c68bbf82d9ef 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-02-01-preview/examples/VirtualNetworkRulesList.json if __name__ == "__main__": main()