From 9aee3d3e113b1da6b088217f3bb57175f65137ad Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 8 Jun 2023 03:32:41 +0000 Subject: [PATCH] CodeGen from PR 24349 in Azure/azure-rest-api-specs Merge 222556f13a3dcf447bdc0b7344e55beef22cc801 into 04d4d832025900d3fb31f4afc20f480840511e5e --- sdk/sql/azure-mgmt-sql/_meta.json | 6 +- .../azure/mgmt/sql/_configuration.py | 6 + .../azure/mgmt/sql/_serialization.py | 6 +- .../azure/mgmt/sql/_sql_management_client.py | 701 +++--- .../azure-mgmt-sql/azure/mgmt/sql/_version.py | 2 +- .../azure/mgmt/sql/aio/_configuration.py | 6 + .../mgmt/sql/aio/_sql_management_client.py | 705 +++--- .../azure/mgmt/sql/aio/operations/__init__.py | 306 ++- ...hort_term_retention_policies_operations.py | 214 +- .../operations/_capabilities_operations.py | 9 +- .../_data_masking_policies_operations.py | 198 +- .../_data_masking_rules_operations.py | 230 +- ...ta_warehouse_user_activities_operations.py | 179 +- ...d_threat_protection_settings_operations.py | 34 +- .../_database_advisors_operations.py | 20 +- .../_database_automatic_tuning_operations.py | 16 +- ...abase_blob_auditing_policies_operations.py | 29 +- .../_database_columns_operations.py | 44 +- ...tabase_encryption_protectors_operations.py | 21 +- .../_database_extensions_operations.py | 213 +- .../_database_operations_operations.py | 157 +- ...database_recommended_actions_operations.py | 20 +- .../_database_schemas_operations.py | 27 +- ...base_security_alert_policies_operations.py | 210 +- ...ability_assessment_baselines_operations.py | 34 +- ...lity_assessment_execute_scan_operations.py | 13 +- ...ty_assessment_rule_baselines_operations.py | 38 +- ...ility_assessment_scan_result_operations.py | 27 +- ...lnerability_assessment_scans_operations.py | 27 +- ...ability_assessments_settings_operations.py | 27 +- .../operations/_database_tables_operations.py | 27 +- .../operations/_database_usages_operations.py | 23 +- ...ty_assessment_rule_baselines_operations.py | 20 +- ...lnerability_assessment_scans_operations.py | 311 ++- ...se_vulnerability_assessments_operations.py | 206 +- .../aio/operations/_databases_operations.py | 320 +-- .../operations/_deleted_servers_operations.py | 172 +- ...tributed_availability_groups_operations.py | 292 ++- .../_elastic_pool_activities_operations.py | 141 -- ...tic_pool_database_activities_operations.py | 142 -- .../_elastic_pool_operations_operations.py | 157 +- .../operations/_elastic_pools_operations.py | 236 +- .../_encryption_protectors_operations.py | 46 +- .../_endpoint_certificates_operations.py | 27 +- ...abase_blob_auditing_policies_operations.py | 29 +- ...erver_blob_auditing_policies_operations.py | 33 +- .../operations/_failover_groups_operations.py | 362 ++- .../operations/_firewall_rules_operations.py | 460 ++-- .../_geo_backup_policies_operations.py | 356 +-- .../_instance_failover_groups_operations.py | 62 +- .../operations/_instance_pools_operations.py | 353 +-- .../_ipv6_firewall_rules_operations.py | 38 +- .../aio/operations/_job_agents_operations.py | 56 +- .../operations/_job_credentials_operations.py | 38 +- .../operations/_job_executions_operations.py | 454 ++-- .../_job_step_executions_operations.py | 27 +- .../aio/operations/_job_steps_operations.py | 409 +-- .../_job_target_executions_operations.py | 248 +- .../_job_target_groups_operations.py | 38 +- .../operations/_job_versions_operations.py | 27 +- .../sql/aio/operations/_jobs_operations.py | 38 +- .../_ledger_digest_uploads_operations.py | 208 +- ..._long_term_retention_backups_operations.py | 1779 ++++++------- ...ion_managed_instance_backups_operations.py | 572 +++-- ...long_term_retention_policies_operations.py | 202 +- .../_maintenance_window_options_operations.py | 9 +- .../_maintenance_windows_operations.py | 16 +- ...hort_term_retention_policies_operations.py | 214 +- ...d_threat_protection_settings_operations.py | 34 +- .../_managed_database_columns_operations.py | 44 +- ...ged_database_move_operations_operations.py | 27 +- .../_managed_database_queries_operations.py | 27 +- ...commended_sensitivity_labels_operations.py | 12 +- ...ged_database_restore_details_operations.py | 9 +- .../_managed_database_schemas_operations.py | 27 +- ...base_security_alert_policies_operations.py | 210 +- ...ged_database_security_events_operations.py | 23 +- ..._database_sensitivity_labels_operations.py | 760 +++--- .../_managed_database_tables_operations.py | 27 +- ..._transparent_data_encryption_operations.py | 202 +- ...ty_assessment_rule_baselines_operations.py | 70 +- ...lnerability_assessment_scans_operations.py | 431 ++-- ...se_vulnerability_assessments_operations.py | 206 +- .../_managed_databases_operations.py | 113 +- ...aged_instance_administrators_operations.py | 46 +- ...d_threat_protection_settings_operations.py | 38 +- ...zure_ad_only_authentications_operations.py | 206 +- .../_managed_instance_dtcs_operations.py | 38 +- ...stance_encryption_protectors_operations.py | 294 ++- .../_managed_instance_keys_operations.py | 46 +- ...long_term_retention_policies_operations.py | 302 ++- ..._managed_instance_operations_operations.py | 31 +- ...private_endpoint_connections_operations.py | 206 +- ...tance_private_link_resources_operations.py | 27 +- ...ed_instance_tde_certificates_operations.py | 16 +- ...ce_vulnerability_assessments_operations.py | 200 +- .../_managed_instances_operations.py | 343 ++- ...anaged_ledger_digest_uploads_operations.py | 46 +- ...hort_term_retention_policies_operations.py | 214 +- .../_managed_server_dns_aliases_operations.py | 56 +- ...rver_security_alert_policies_operations.py | 220 +- ...ity_perimeter_configurations_operations.py | 349 +++ .../mgmt/sql/aio/operations/_operations.py | 23 +- .../_outbound_firewall_rules_operations.py | 319 +-- ...private_endpoint_connections_operations.py | 206 +- .../_private_link_resources_operations.py | 27 +- ...commended_sensitivity_labels_operations.py | 12 +- .../_recoverable_databases_operations.py | 27 +- ...ecoverable_managed_databases_operations.py | 27 +- .../_replication_links_operations.py | 68 +- ...restorable_dropped_databases_operations.py | 27 +- ...le_dropped_managed_databases_operations.py | 27 +- .../operations/_restore_points_operations.py | 42 +- .../_sensitivity_labels_operations.py | 502 ++-- ...d_threat_protection_settings_operations.py | 38 +- .../operations/_server_advisors_operations.py | 20 +- .../_server_automatic_tuning_operations.py | 16 +- ...rver_azure_ad_administrators_operations.py | 206 +- ...zure_ad_only_authentications_operations.py | 206 +- ...erver_blob_auditing_policies_operations.py | 33 +- .../_server_communication_links_operations.py | 511 ---- ...server_configuration_options_operations.py | 38 +- .../_server_connection_policies_operations.py | 196 +- ...erver_dev_ops_audit_settings_operations.py | 38 +- .../_server_dns_aliases_operations.py | 210 +- .../aio/operations/_server_keys_operations.py | 46 +- .../_server_operations_operations.py | 23 +- ...rver_security_alert_policies_operations.py | 220 +- .../_server_trust_certificates_operations.py | 46 +- .../_server_trust_groups_operations.py | 219 +- .../operations/_server_usages_operations.py | 25 +- ...er_vulnerability_assessments_operations.py | 198 +- .../sql/aio/operations/_servers_operations.py | 97 +- .../_service_objectives_operations.py | 205 -- .../aio/operations/_sql_agent_operations.py | 16 +- ...rability_assessment_baseline_operations.py | 22 +- ...ability_assessment_baselines_operations.py | 7 +- ...lity_assessment_execute_scan_operations.py | 8 +- ...ity_assessment_rule_baseline_operations.py | 29 +- ...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 | 9 +- ...ability_assessments_settings_operations.py | 34 +- ...p_managed_instance_schedules_operations.py | 38 +- .../_subscription_usages_operations.py | 27 +- .../_synapse_link_workspaces_operations.py | 23 +- .../aio/operations/_sync_agents_operations.py | 223 +- .../aio/operations/_sync_groups_operations.py | 1271 +++++----- .../operations/_sync_members_operations.py | 441 ++-- .../_tde_certificates_operations.py | 16 +- .../aio/operations/_time_zones_operations.py | 27 +- ...transparent_data_encryptions_operations.py | 38 +- .../sql/aio/operations/_usages_operations.py | 23 +- .../_virtual_clusters_operations.py | 71 +- .../_virtual_network_rules_operations.py | 202 +- .../_workload_classifiers_operations.py | 216 +- .../operations/_workload_groups_operations.py | 208 +- .../azure/mgmt/sql/models/__init__.py | 102 +- .../azure/mgmt/sql/models/_models_py3.py | 2216 +++++++++------- .../models/_sql_management_client_enums.py | 210 +- .../azure/mgmt/sql/operations/__init__.py | 306 ++- ...hort_term_retention_policies_operations.py | 268 +- .../operations/_capabilities_operations.py | 13 +- .../_data_masking_policies_operations.py | 236 +- .../_data_masking_rules_operations.py | 270 +- ...ta_warehouse_user_activities_operations.py | 215 +- ...d_threat_protection_settings_operations.py | 46 +- .../_database_advisors_operations.py | 32 +- .../_database_automatic_tuning_operations.py | 24 +- ...abase_blob_auditing_policies_operations.py | 41 +- .../_database_columns_operations.py | 56 +- ...tabase_encryption_protectors_operations.py | 29 +- .../_database_extensions_operations.py | 275 +- .../_database_operations_operations.py | 205 +- ...database_recommended_actions_operations.py | 32 +- .../_database_schemas_operations.py | 35 +- ...base_security_alert_policies_operations.py | 256 +- ...ability_assessment_baselines_operations.py | 46 +- ...lity_assessment_execute_scan_operations.py | 17 +- ...ty_assessment_rule_baselines_operations.py | 54 +- ...ility_assessment_scan_result_operations.py | 35 +- ...lnerability_assessment_scans_operations.py | 35 +- ...ability_assessments_settings_operations.py | 35 +- .../operations/_database_tables_operations.py | 35 +- .../operations/_database_usages_operations.py | 27 +- ...ty_assessment_rule_baselines_operations.py | 32 +- ...lnerability_assessment_scans_operations.py | 365 ++- ...se_vulnerability_assessments_operations.py | 276 +- .../sql/operations/_databases_operations.py | 439 +--- .../operations/_deleted_servers_operations.py | 198 +- ...tributed_availability_groups_operations.py | 352 ++- .../_elastic_pool_activities_operations.py | 176 -- ...tic_pool_database_activities_operations.py | 176 -- .../_elastic_pool_operations_operations.py | 205 +- .../operations/_elastic_pools_operations.py | 329 +-- .../_encryption_protectors_operations.py | 62 +- .../_endpoint_certificates_operations.py | 35 +- ...abase_blob_auditing_policies_operations.py | 41 +- ...erver_blob_auditing_policies_operations.py | 45 +- .../operations/_failover_groups_operations.py | 437 ++-- .../operations/_firewall_rules_operations.py | 532 ++-- .../_geo_backup_policies_operations.py | 400 +-- .../_instance_failover_groups_operations.py | 86 +- .../operations/_instance_pools_operations.py | 445 ++-- .../_ipv6_firewall_rules_operations.py | 54 +- .../sql/operations/_job_agents_operations.py | 76 +- .../operations/_job_credentials_operations.py | 54 +- .../operations/_job_executions_operations.py | 586 +++-- .../_job_step_executions_operations.py | 35 +- .../sql/operations/_job_steps_operations.py | 507 ++-- .../_job_target_executions_operations.py | 322 +-- .../_job_target_groups_operations.py | 54 +- .../operations/_job_versions_operations.py | 35 +- .../mgmt/sql/operations/_jobs_operations.py | 54 +- .../_ledger_digest_uploads_operations.py | 260 +- ..._long_term_retention_backups_operations.py | 2225 ++++++++--------- ...ion_managed_instance_backups_operations.py | 788 +++--- ...long_term_retention_policies_operations.py | 250 +- .../_maintenance_window_options_operations.py | 13 +- .../_maintenance_windows_operations.py | 24 +- ...hort_term_retention_policies_operations.py | 270 +- ...d_threat_protection_settings_operations.py | 46 +- .../_managed_database_columns_operations.py | 56 +- ...ged_database_move_operations_operations.py | 35 +- .../_managed_database_queries_operations.py | 35 +- ...commended_sensitivity_labels_operations.py | 16 +- ...ged_database_restore_details_operations.py | 13 +- .../_managed_database_schemas_operations.py | 35 +- ...base_security_alert_policies_operations.py | 256 +- ...ged_database_security_events_operations.py | 27 +- ..._database_sensitivity_labels_operations.py | 1045 ++++---- .../_managed_database_tables_operations.py | 35 +- ..._transparent_data_encryption_operations.py | 248 +- ...ty_assessment_rule_baselines_operations.py | 82 +- ...lnerability_assessment_scans_operations.py | 485 ++-- ...se_vulnerability_assessments_operations.py | 276 +- .../_managed_databases_operations.py | 153 +- ...aged_instance_administrators_operations.py | 62 +- ...d_threat_protection_settings_operations.py | 50 +- ...zure_ad_only_authentications_operations.py | 272 +- .../_managed_instance_dtcs_operations.py | 50 +- ...stance_encryption_protectors_operations.py | 362 ++- .../_managed_instance_keys_operations.py | 62 +- ...long_term_retention_policies_operations.py | 357 ++- ..._managed_instance_operations_operations.py | 43 +- ...private_endpoint_connections_operations.py | 276 +- ...tance_private_link_resources_operations.py | 35 +- ...ed_instance_tde_certificates_operations.py | 20 +- ...ce_vulnerability_assessments_operations.py | 270 +- .../_managed_instances_operations.py | 520 +++- ...anaged_ledger_digest_uploads_operations.py | 62 +- ...hort_term_retention_policies_operations.py | 258 +- .../_managed_server_dns_aliases_operations.py | 76 +- ...rver_security_alert_policies_operations.py | 266 +- ...ity_perimeter_configurations_operations.py | 442 ++++ .../azure/mgmt/sql/operations/_operations.py | 27 +- .../_outbound_firewall_rules_operations.py | 374 +-- ...private_endpoint_connections_operations.py | 274 +- .../_private_link_resources_operations.py | 35 +- ...commended_sensitivity_labels_operations.py | 16 +- .../_recoverable_databases_operations.py | 35 +- ...ecoverable_managed_databases_operations.py | 35 +- .../_replication_links_operations.py | 92 +- ...restorable_dropped_databases_operations.py | 35 +- ...le_dropped_managed_databases_operations.py | 35 +- .../operations/_restore_points_operations.py | 58 +- .../_sensitivity_labels_operations.py | 717 +++--- ...d_threat_protection_settings_operations.py | 50 +- .../operations/_server_advisors_operations.py | 32 +- .../_server_automatic_tuning_operations.py | 24 +- ...rver_azure_ad_administrators_operations.py | 270 +- ...zure_ad_only_authentications_operations.py | 270 +- ...erver_blob_auditing_policies_operations.py | 45 +- .../_server_communication_links_operations.py | 632 ----- ...server_configuration_options_operations.py | 50 +- .../_server_connection_policies_operations.py | 242 +- ...erver_dev_ops_audit_settings_operations.py | 50 +- .../_server_dns_aliases_operations.py | 266 +- .../sql/operations/_server_keys_operations.py | 62 +- .../_server_operations_operations.py | 27 +- ...rver_security_alert_policies_operations.py | 266 +- .../_server_trust_certificates_operations.py | 62 +- .../_server_trust_groups_operations.py | 281 +-- .../operations/_server_usages_operations.py | 29 +- ...er_vulnerability_assessments_operations.py | 266 +- .../sql/operations/_servers_operations.py | 133 +- .../_service_objectives_operations.py | 270 -- .../sql/operations/_sql_agent_operations.py | 24 +- ...rability_assessment_baseline_operations.py | 30 +- ...ability_assessment_baselines_operations.py | 11 +- ...lity_assessment_execute_scan_operations.py | 12 +- ...ity_assessment_rule_baseline_operations.py | 41 +- ...ty_assessment_rule_baselines_operations.py | 8 +- ...ility_assessment_scan_result_operations.py | 30 +- ...lnerability_assessment_scans_operations.py | 30 +- ...ql_vulnerability_assessments_operations.py | 13 +- ...ability_assessments_settings_operations.py | 46 +- ...p_managed_instance_schedules_operations.py | 54 +- .../_subscription_usages_operations.py | 35 +- .../_synapse_link_workspaces_operations.py | 27 +- .../sql/operations/_sync_agents_operations.py | 289 ++- .../sql/operations/_sync_groups_operations.py | 1511 ++++++----- .../operations/_sync_members_operations.py | 541 ++-- .../_tde_certificates_operations.py | 20 +- .../sql/operations/_time_zones_operations.py | 35 +- ...transparent_data_encryptions_operations.py | 50 +- .../mgmt/sql/operations/_usages_operations.py | 27 +- .../_virtual_clusters_operations.py | 95 +- .../_virtual_network_rules_operations.py | 260 +- .../_workload_classifiers_operations.py | 272 +- .../operations/_workload_groups_operations.py | 276 +- .../administrator_create_or_update.py | 2 +- .../generated_samples/administrator_delete.py | 5 +- .../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 | 5 +- .../azure_ad_only_auth_get.py | 2 +- .../azure_ad_only_auth_list.py | 2 +- .../cancel_database_operation.py | 5 +- .../cancel_elastic_pool_operation.py | 5 +- .../generated_samples/cancel_job_execution.py | 5 +- .../cancel_managed_instance_operation.py | 5 +- ...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 | 2 +- .../column_sensitivity_label_delete.py | 5 +- .../column_sensitivity_label_get.py | 2 +- .../columns_list_by_database_max.py | 2 +- .../columns_list_by_database_min.py | 2 +- ...se_configured_backup_storage_redundancy.py | 2 +- .../create_database_copy_mode.py | 2 +- .../create_database_default_enclave.py | 2 +- .../create_database_default_mode.py | 2 +- ...mode_with_keys_and_encryption_protector.py | 2 +- .../create_database_ledger.py | 2 +- ...eate_database_maintenance_configuration.py | 2 +- .../generated_samples/create_database_min.py | 2 +- .../create_database_named_replica.py | 2 +- .../create_database_pitr_mode.py | 2 +- .../create_database_secondary_mode.py | 2 +- .../create_database_standby_mode.py | 2 +- .../create_database_vbs_enclave.py | 2 +- .../create_database_with_availability_zone.py | 2 +- ...ate_dw_database_cross_subscription_pitr.py | 2 +- ...dw_database_cross_subscription_recovery.py | 2 +- ..._dw_database_cross_subscription_restore.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 | 5 +- ...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 +- ...ate_vcore_database_by_service_objective.py | 2 +- ...ate_vcore_database_by_sku_name_capacity.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 | 5 +- .../database_encryption_protector_revert.py | 5 +- ...atabase_extended_auditing_settings_list.py | 2 +- .../database_metrics_list_with_filter.py | 44 - .../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 | 5 +- .../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 | 5 +- ...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 | 5 +- ..._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 | 5 +- .../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 | 5 +- ...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 | 5 +- .../generated_samples/delete_database.py | 5 +- .../generated_samples/delete_instance_pool.py | 5 +- .../generated_samples/delete_job.py | 5 +- .../generated_samples/delete_job_agent.py | 5 +- .../delete_job_credential.py | 5 +- .../generated_samples/delete_job_step.py | 5 +- .../delete_job_target_group.py | 5 +- .../delete_workload_classifier.py | 5 +- .../delete_workload_group.py | 5 +- .../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 | 5 +- .../distributed_availability_groups_get.py | 2 +- ...ed_availability_groups_list_by_instance.py | 2 +- ...istributed_availability_groups_set_role.py | 43 + .../distributed_availability_groups_update.py | 2 +- .../elastic_pool_activity_list.py | 43 - .../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 | 5 +- .../generated_samples/elastic_pool_get.py | 2 +- ...ic_pool_get_with_preferred_enclave_type.py | 2 +- .../elastic_pool_list_by_server.py | 2 +- .../elastic_pool_metrics_list_with_filter.py | 44 - ...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 | 5 +- .../endpoint_certificates_get.py | 2 +- .../endpoint_certificates_list_by_instance.py | 2 +- .../generated_samples/export_database.py | 2 +- ...port_database_using_database_extensions.py | 54 + .../export_database_with_network_isolation.py | 2 +- ...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 +- .../generated_samples/failover_database.py | 5 +- .../failover_elastic_pool.py | 5 +- .../failover_group_create_or_update.py | 2 +- .../failover_group_delete.py | 5 +- .../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 +- ...oup_try_planned_before_forced_failover.py} | 14 +- .../failover_group_update.py | 2 +- .../failover_managed_instance.py | 5 +- .../generated_samples/firewall_rule_create.py | 2 +- .../generated_samples/firewall_rule_delete.py | 5 +- .../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 | 5 +- .../generated_samples/get_database_usages.py | 2 +- .../get_database_with_availability_zone.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 +- .../generated_samples/get_vcore_database.py | 2 +- .../get_vcore_database_default_enclave.py | 2 +- .../get_vcore_database_vbs_enclave.py | 2 +- ..._vcore_database_with_expand_equals_keys.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 +- .../generated_samples/import_database.py | 2 +- ...port_database_using_database_extensions.py | 54 + .../import_database_with_network_isolation.py | 2 +- .../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 | 5 +- .../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 | 5 +- .../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_databases_by_elastic_pool.py | 2 +- .../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 +- .../list_vcore_databases_by_server.py | 2 +- ..._vcore_databases_enclave_type_by_server.py | 2 +- ..._vcore_inaccessible_databases_by_server.py | 2 +- .../location_capability_list_by_location.py | 2 +- .../long_term_retention_backup_copy.py | 2 +- .../long_term_retention_backup_delete.py | 5 +- .../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 | 2 +- .../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 | 5 +- .../managed_database_column_get.py | 2 +- .../managed_database_column_list_by_table.py | 2 +- ...atabase_column_sensitivity_label_create.py | 2 +- ...atabase_column_sensitivity_label_delete.py | 5 +- ...d_database_column_sensitivity_label_get.py | 2 +- ...aged_database_complete_external_restore.py | 5 +- .../managed_database_complete_move.py | 5 +- ...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 | 5 +- .../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 | 5 +- ...mmended_column_sensitivity_label_enable.py | 5 +- .../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 | 5 +- ...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 | 5 +- .../managed_database_start_move_max.py | 5 +- .../managed_database_start_move_min.py | 5 +- .../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 | 5 +- ...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 | 5 +- ...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 | 5 +- .../managed_instance_administrator_create.py | 2 +- .../managed_instance_administrator_delete.py | 5 +- .../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 | 5 +- ...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 | 7 +- .../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 | 5 +- .../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 | 5 +- .../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 | 5 +- ...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 +- ...tance_long_term_retention_policy_delete.py | 43 + ...instance_long_term_retention_policy_get.py | 2 +- ..._term_retention_policy_list_by_database.py | 2 +- ...ance_private_endpoint_connection_delete.py | 5 +- ...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 | 5 +- .../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 | 6 +- .../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 | 5 +- ...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 | 5 +- .../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 +- ...te.py => outbound_firewall_rule_create.py} | 10 +- .../outbound_firewall_rule_delete.py | 5 +- .../outbound_firewall_rule_get.py | 2 +- .../outbound_firewall_rule_list.py | 2 +- .../patch_database_default_enclave.py | 2 +- .../patch_database_vbs_enclave.py | 2 +- .../generated_samples/patch_instance_pool.py | 2 +- .../generated_samples/patch_vcore_database.py | 2 +- ...tabase_assign_maintenance_configuration.py | 2 +- ...atabase_reset_maintenance_configuration.py | 2 +- ...base_with_keys_and_encryption_protector.py | 2 +- .../generated_samples/pause_database.py | 2 +- .../private_endpoint_connection_delete.py | 5 +- .../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 | 5 +- ...mmended_column_sensitivity_label_enable.py | 5 +- .../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} | 11 +- .../generated_samples/rename_database.py | 5 +- .../replication_link_delete.py | 5 +- .../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 | 5 +- ...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 | 7 +- ...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 +- .../generated_samples/resume_database.py | 2 +- .../sensitivity_labels_current_update.py | 5 +- ...=> 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 | 5 +- ...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 | 2 +- .../generated_samples/server_delete.py | 5 +- .../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 | 5 +- .../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 | 5 +- .../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 | 5 +- .../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 | 5 +- .../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 | 2 +- ...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 | 5 +- .../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 | 5 +- ...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 | 5 +- .../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 | 5 +- ...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 | 5 +- ..._vulnerability_assessment_scans_results.py | 2 +- .../start_managed_instance.py | 2 +- ..._instance_schedule_create_or_update_max.py | 2 +- ..._instance_schedule_create_or_update_min.py | 2 +- ...t_stop_managed_instance_schedule_delete.py | 5 +- ...tart_stop_managed_instance_schedule_get.py | 2 +- ...art_stop_managed_instance_schedule_list.py | 2 +- .../stop_managed_instance.py | 2 +- .../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 | 5 +- .../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 | 5 +- .../generated_samples/sync_group_create.py | 2 +- .../generated_samples/sync_group_delete.py | 5 +- .../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 | 5 +- .../sync_group_trigger_sync.py | 5 +- .../generated_samples/sync_group_update.py | 2 +- .../generated_samples/sync_member_create.py | 2 +- .../generated_samples/sync_member_delete.py | 5 +- .../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 | 5 +- .../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 +- ...se_hyperscale_migration_perform_cutover.py | 2 +- ...yperscale_migration_with_manual_cutover.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 +- .../upgrade_data_warehouse.py | 5 +- .../virtual_cluster_delete.py | 5 +- .../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 | 5 +- .../virtual_network_rules_get.py | 2 +- .../virtual_network_rules_list.py | 2 +- 965 files changed, 27426 insertions(+), 28666 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 create mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py delete mode 100644 sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py 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%) delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_list_with_filter.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_database_activity_list.py delete mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_list_with_filter.py create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py rename sdk/sql/azure-mgmt-sql/generated_samples/{service_objective_get.py => failover_group_try_planned_before_forced_failover.py} (76%) 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_metrics_definitions_list.py => managed_database_sensitivity_labels_list_by_database.py} (78%) create mode 100644 sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py 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_delete.py => outbound_firewall_rule_create.py} (84%) rename sdk/sql/azure-mgmt-sql/generated_samples/{server_communication_link_get.py => refresh_external_governance_status_mi.py} (83%) 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 86f3d6e44ee2..5f11119adc1a 100644 --- a/sdk/sql/azure-mgmt-sql/_meta.json +++ b/sdk/sql/azure-mgmt-sql/_meta.json @@ -1,11 +1,11 @@ { - "commit": "f66499b77cd90144ceb0d118c1bd8bda7dbd4cfc", + "commit": "3e6d63f449c0b7b277f73bbdbf8389c5b16d543b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.4.3", + "@autorest/python@6.5.0", "@autorest/modelerfour@4.24.3" ], - "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 --use=@autorest/python@6.4.3 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --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.5.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --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/_serialization.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_serialization.py index f17c068e833e..842ae727fbbc 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_serialization.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_serialization.py @@ -629,7 +629,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -1271,7 +1271,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1295,7 +1295,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): 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 677fd4d07fc5..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,32 +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 @@ -247,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 @@ -259,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 @@ -273,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 @@ -286,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: @@ -296,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: @@ -339,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 @@ -370,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 @@ -382,142 +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 servers: ServersOperations operations + :vartype servers: azure.mgmt.sql.operations.ServersOperations :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 ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.operations.IPv6FirewallRulesOperations - :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 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 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 sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations operations :vartype sql_vulnerability_assessment_baseline: @@ -552,53 +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 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 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.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 ) @@ -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,33 +667,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 ) @@ -699,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 ) @@ -712,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 ) @@ -727,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 ) @@ -738,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 ) @@ -774,181 +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._client, self._config, self._serialize, self._deserialize - ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + 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.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + 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.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( 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.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_operations = ServerOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( 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.server_trust_groups = ServerTrustGroupsOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.replication_links = ReplicationLinksOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -976,52 +977,36 @@ def __init__( self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self.subscription_usages = SubscriptionUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) self.synapse_link_workspaces = SynapseLinkWorkspacesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_databases = ManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_instances = ManagedInstancesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.recoverable_databases = RecoverableDatabasesOperations( + 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.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + 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.server_configuration_options = ServerConfigurationOptionsOperations( + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations( 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.virtual_network_rules = VirtualNetworkRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + 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 33bbcd0f5f26..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.0b10" +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 c3f0178e2eb9..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,32 +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 @@ -248,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 @@ -260,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 @@ -274,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 @@ -290,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: @@ -300,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: @@ -343,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 @@ -374,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 @@ -386,143 +511,20 @@ 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 subscription_usages: SubscriptionUsagesOperations operations - :vartype subscription_usages: azure.mgmt.sql.aio.operations.SubscriptionUsagesOperations - :ivar sync_agents: SyncAgentsOperations operations - :vartype sync_agents: azure.mgmt.sql.aio.operations.SyncAgentsOperations - :ivar sync_groups: SyncGroupsOperations operations - :vartype sync_groups: azure.mgmt.sql.aio.operations.SyncGroupsOperations - :ivar sync_members: SyncMembersOperations operations - :vartype sync_members: azure.mgmt.sql.aio.operations.SyncMembersOperations - :ivar tde_certificates: TdeCertificatesOperations operations - :vartype tde_certificates: azure.mgmt.sql.aio.operations.TdeCertificatesOperations - :ivar time_zones: TimeZonesOperations operations - :vartype time_zones: azure.mgmt.sql.aio.operations.TimeZonesOperations - :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 ipv6_firewall_rules: IPv6FirewallRulesOperations operations - :vartype ipv6_firewall_rules: azure.mgmt.sql.aio.operations.IPv6FirewallRulesOperations - :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 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 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 sql_vulnerability_assessment_baseline: SqlVulnerabilityAssessmentBaselineOperations operations :vartype sql_vulnerability_assessment_baseline: @@ -557,54 +559,46 @@ class SqlManagementClient: # pylint: disable=client-accepts-api-version-keyword :ivar sql_vulnerability_assessments: SqlVulnerabilityAssessmentsOperations operations :vartype sql_vulnerability_assessments: azure.mgmt.sql.aio.operations.SqlVulnerabilityAssessmentsOperations - :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 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 + :vartype sync_groups: azure.mgmt.sql.aio.operations.SyncGroupsOperations + :ivar sync_members: SyncMembersOperations operations + :vartype sync_members: azure.mgmt.sql.aio.operations.SyncMembersOperations + :ivar tde_certificates: TdeCertificatesOperations operations + :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 :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,33 +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 ) @@ -705,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 ) @@ -718,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 ) @@ -733,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 ) @@ -744,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 ) @@ -780,181 +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._client, self._config, self._serialize, self._deserialize - ) - self.server_connection_policies = ServerConnectionPoliciesOperations( + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.distributed_availability_groups = DistributedAvailabilityGroupsOperations( + self.private_link_resources = PrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_trust_certificates = ServerTrustCertificatesOperations( + self.recoverable_databases = RecoverableDatabasesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.ipv6_firewall_rules = IPv6FirewallRulesOperations( + 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.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_blob_auditing_policies = DatabaseBlobAuditingPoliciesOperations( + 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.extended_database_blob_auditing_policies = ExtendedDatabaseBlobAuditingPoliciesOperations( + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.extended_server_blob_auditing_policies = ExtendedServerBlobAuditingPoliciesOperations( + self.server_azure_ad_only_authentications = ServerAzureADOnlyAuthenticationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_advanced_threat_protection_settings = DatabaseAdvancedThreatProtectionSettingsOperations( + self.server_configuration_options = ServerConfigurationOptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.server_advanced_threat_protection_settings = ServerAdvancedThreatProtectionSettingsOperations( + self.server_connection_policies = ServerConnectionPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_server_dns_aliases = ManagedServerDnsAliasesOperations( + self.server_dev_ops_audit_settings = ServerDevOpsAuditSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_baselines = DatabaseSqlVulnerabilityAssessmentBaselinesOperations( + self.server_dns_aliases = ServerDnsAliasesOperations( 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.server_keys = ServerKeysOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_operations = ServerOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessment_scans = DatabaseSqlVulnerabilityAssessmentScansOperations( + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.database_sql_vulnerability_assessments_settings = DatabaseSqlVulnerabilityAssessmentsSettingsOperations( + self.server_trust_certificates = ServerTrustCertificatesOperations( 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.server_trust_groups = ServerTrustGroupsOperations( + self._client, self._config, self._serialize, self._deserialize ) - self.replication_links = ReplicationLinksOperations( + self.server_usages = ServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.server_vulnerability_assessments = ServerVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_agent = SqlAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_vulnerability_assessment_baseline = SqlVulnerabilityAssessmentBaselineOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -982,52 +983,36 @@ def __init__( self.sql_vulnerability_assessments = SqlVulnerabilityAssessmentsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_database_move_operations = ManagedDatabaseMoveOperationsOperations( + self.start_stop_managed_instance_schedules = StartStopManagedInstanceSchedulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.managed_instance_dtcs = ManagedInstanceDtcsOperations( + self.subscription_usages = SubscriptionUsagesOperations( self._client, self._config, self._serialize, self._deserialize ) self.synapse_link_workspaces = SynapseLinkWorkspacesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.virtual_clusters = VirtualClustersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.instance_failover_groups = InstanceFailoverGroupsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_database_restore_details = ManagedDatabaseRestoreDetailsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.database_encryption_protectors = DatabaseEncryptionProtectorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_databases = ManagedDatabasesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_instances = ManagedInstancesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.managed_ledger_digest_uploads = ManagedLedgerDigestUploadsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.recoverable_databases = RecoverableDatabasesOperations( + 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.restorable_dropped_databases = RestorableDroppedDatabasesOperations( + 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.server_configuration_options = ServerConfigurationOptionsOperations( + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_clusters = VirtualClustersOperations( 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.virtual_network_rules = VirtualNetworkRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.transparent_data_encryptions = TransparentDataEncryptionsOperations( + 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 d6642f431e59..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,67 +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 ( @@ -79,87 +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 ._servers_operations import ServersOperations 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 ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations -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 ._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 ._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 ._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,81 +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 ._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 ._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", @@ -252,69 +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", + "ServersOperations", "SqlAgentOperations", - "SubscriptionUsagesOperations", - "SyncAgentsOperations", - "SyncGroupsOperations", - "SyncMembersOperations", - "TdeCertificatesOperations", - "TimeZonesOperations", - "VirtualNetworkRulesOperations", - "WorkloadClassifiersOperations", - "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseOperationsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "DistributedAvailabilityGroupsOperations", - "ServerTrustCertificatesOperations", - "IPv6FirewallRulesOperations", - "EndpointCertificatesOperations", - "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", - "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", - "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", - "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", - "ReplicationLinksOperations", "SqlVulnerabilityAssessmentBaselineOperations", "SqlVulnerabilityAssessmentBaselinesOperations", "SqlVulnerabilityAssessmentExecuteScanOperations", @@ -324,22 +320,20 @@ "SqlVulnerabilityAssessmentScansOperations", "SqlVulnerabilityAssessmentsSettingsOperations", "SqlVulnerabilityAssessmentsOperations", - "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", - "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", - "ManagedInstancesOperations", - "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", - "ServersOperations", "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 1cc566a3960c..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_update_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]] @@ -64,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, @@ -100,9 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -161,16 +252,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "BackupShortTermRetentionPolicy") @@ -346,9 +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: Literal["2021-02-01-preview"] = 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) @@ -415,16 +502,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "BackupShortTermRetentionPolicy") @@ -600,9 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) @@ -648,90 +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: Literal["2021-02-01-preview"] = 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 d1c87f0c52d2..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._capabilities_operations import build_list_by_location_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]] @@ -84,9 +79,7 @@ async def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 3aa1e3dd0251..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,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]] @@ -55,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", @@ -75,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 @@ -96,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", @@ -110,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 @@ -131,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: @@ -143,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 @@ -169,15 +241,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingPolicy") @@ -186,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, @@ -206,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: Literal["2014-04-01"] = 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 6879aed1e5b2..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -30,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]] @@ -57,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, *, @@ -78,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. @@ -86,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 @@ -102,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, *, @@ -117,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. @@ -125,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 @@ -141,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 @@ -154,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 @@ -182,15 +282,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingRule") @@ -199,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, @@ -238,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: Literal["2014-04-01"] = 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 a5d9f29d6cfd..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 @@ -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. # -------------------------------------------------------------------------- -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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._data_warehouse_user_activities_operations import build_get_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]] @@ -57,85 +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: Literal["2020-11-01-preview"] = 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 @@ -159,9 +76,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -189,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" @@ -222,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 23a17b611cf7..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ 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]] @@ -84,9 +81,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -114,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" @@ -186,9 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -344,16 +348,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseAdvancedThreatProtection") 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 fb90631ec381..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,10 +32,6 @@ build_update_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]] @@ -95,9 +91,7 @@ async def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -167,9 +161,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -319,16 +311,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Advisor") 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 743fee8e3859..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._database_automatic_tuning_operations import build_get_request, build_update_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]] @@ -84,9 +80,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -226,16 +220,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseAutomaticTuning") 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 8c3dd63f35c3..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -84,9 +86,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -114,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" @@ -181,9 +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: Literal["2021-11-01-preview"] = 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( @@ -334,16 +343,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseBlobAuditingPolicy") 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 87b32a214af9..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -34,10 +34,6 @@ build_list_by_table_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]] @@ -102,9 +98,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -137,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" @@ -206,9 +211,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -239,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" @@ -315,9 +329,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 32ac89b422c7..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._database_encryption_protectors_operations import build_revalidate_request, build_revert_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]] @@ -76,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -149,9 +142,7 @@ async def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -214,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -287,9 +276,7 @@ async def begin_revert( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 e5592c777026..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ 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]] @@ -63,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 @@ -94,9 +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: Literal["2021-02-01-preview"] = 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( @@ -151,16 +242,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseExtensions") @@ -218,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. @@ -261,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. @@ -302,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. @@ -336,9 +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: Literal["2021-02-01-preview"] = 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) @@ -384,90 +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: Literal["2021-02-01-preview"] = 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 db238f0ee854..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._database_operations_operations import build_cancel_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]] @@ -57,74 +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: Literal["2021-02-01-preview"] = 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 @@ -146,9 +74,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -176,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" @@ -209,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 f74a3599c174..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,10 +32,6 @@ build_update_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]] @@ -90,9 +86,7 @@ async def list_by_database_advisor( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -170,9 +164,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -332,16 +324,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedAction") 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 b0fd4b60ce6f..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._database_schemas_operations import build_get_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]] @@ -86,9 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -117,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" @@ -182,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 22bd8b647458..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ 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]] @@ -61,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, @@ -80,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) @@ -98,9 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -161,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 @@ -196,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 @@ -229,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. @@ -253,16 +345,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSecurityAlertPolicy") @@ -309,91 +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: Literal["2020-11-01-preview"] = 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 7f49e2f90207..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ build_list_by_sql_vulnerability_assessment_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]] @@ -92,9 +89,7 @@ def list_by_sql_vulnerability_assessment( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -123,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" @@ -199,9 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( @@ -366,16 +370,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") 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 5b5b47d44f37..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._database_sql_vulnerability_assessment_execute_scan_operations import build_execute_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]] @@ -76,9 +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: Literal["2022-02-01-preview"] = 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_execute_request( @@ -149,9 +142,7 @@ async def begin_execute( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) 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 79536949963f..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_baseline_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]] @@ -96,9 +93,7 @@ def list_by_baseline( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -128,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" @@ -207,9 +213,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -383,16 +387,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") @@ -481,9 +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: Literal["2022-02-01-preview"] = 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( 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 fd95e921cbe1..6e5e49667603 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 @@ -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. # -------------------------------------------------------------------------- -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 ( @@ -33,10 +33,6 @@ build_list_by_scan_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]] @@ -96,9 +92,7 @@ def list_by_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -128,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" @@ -207,9 +212,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 633af5b123fd..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 @@ -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. # -------------------------------------------------------------------------- -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 ( @@ -33,10 +33,6 @@ build_list_by_sql_vulnerability_assessments_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]] @@ -91,9 +87,7 @@ def list_by_sql_vulnerability_assessments( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -122,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" @@ -196,9 +201,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 7783234209b2..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 @@ -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. # -------------------------------------------------------------------------- -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 ( @@ -33,10 +33,6 @@ 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]] @@ -83,9 +79,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -113,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" @@ -185,9 +190,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 e5f1f186eab1..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._database_tables_operations import build_get_request, build_list_by_schema_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]] @@ -89,9 +85,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -121,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" @@ -194,9 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 b3cc39873b22..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._database_usages_operations import 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]] @@ -77,9 +73,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -107,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 9289b9df0561..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,10 +32,6 @@ 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]] @@ -105,9 +101,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -289,16 +283,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") @@ -390,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 3b8634254384..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -37,10 +37,6 @@ 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]] @@ -64,148 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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, @@ -237,9 +91,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -268,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" @@ -342,9 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -424,9 +285,7 @@ async def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -469,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 1a5b7d6941e7..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ 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]] @@ -62,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, @@ -100,9 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -258,16 +350,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") @@ -353,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -389,91 +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: Literal["2020-11-01-preview"] = 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 3188f24a90c2..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -49,10 +48,6 @@ build_upgrade_data_warehouse_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]] @@ -76,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 @@ -267,9 +92,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -297,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" @@ -371,9 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) request = build_get_request( @@ -432,16 +264,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Database") @@ -607,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -672,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -736,9 +562,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -800,16 +624,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseUpdate") @@ -972,9 +794,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1041,16 +861,14 @@ async def _export_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExportDatabaseDefinition") @@ -1213,9 +1031,7 @@ async def begin_export( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1280,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1353,9 +1167,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1416,16 +1228,14 @@ async def _import_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ImportExistingDatabaseDefinition") @@ -1588,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1738,16 +1546,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ResourceMoveDefinition") @@ -1800,9 +1606,7 @@ async def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) request = build_pause_request( @@ -1871,9 +1675,7 @@ async def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1930,9 +1732,7 @@ async def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) request = build_resume_request( @@ -2001,9 +1801,7 @@ async def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2060,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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_upgrade_data_warehouse_request( @@ -2124,9 +1920,7 @@ async def begin_upgrade_data_warehouse( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -2188,9 +1982,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2218,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" @@ -2271,9 +2074,7 @@ def list_inaccessible_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2300,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 d314d8659ba8..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -37,10 +37,6 @@ build_recover_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]] @@ -76,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -103,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" @@ -135,69 +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: Literal["2020-11-01-preview"] = 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. @@ -212,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -240,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" @@ -274,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]: @@ -288,9 +300,7 @@ async def _recover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -355,9 +365,7 @@ async def begin_recover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 5895167c3c64..7665bef01e65 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,13 +36,10 @@ build_delete_request, build_get_request, build_list_by_instance_request, + build_set_role_request, build_update_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]] @@ -86,9 +84,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -115,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" @@ -182,9 +189,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -241,16 +246,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") @@ -416,9 +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: Literal["2021-11-01-preview"] = 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) @@ -482,9 +483,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -550,9 +549,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -612,16 +609,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") @@ -784,9 +779,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -831,3 +824,238 @@ 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, **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 c0cfe703ce7e..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,141 +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. -# -------------------------------------------------------------------------- -import sys -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 - -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]] - - -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: Literal["2014-04-01"] = 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 1d7f4adaa373..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,142 +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. -# -------------------------------------------------------------------------- -import sys -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 - -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]] - - -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: Literal["2014-04-01"] = 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 c5cd6fa7eaa7..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._elastic_pool_operations_operations import build_cancel_request, build_list_by_elastic_pool_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]] @@ -57,74 +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: Literal["2020-11-01-preview"] = 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 @@ -147,9 +75,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -177,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" @@ -210,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 afeb6c1a4a97..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,15 +37,9 @@ build_failover_request, build_get_request, build_list_by_server_request, - build_list_metric_definitions_request, - build_list_metrics_request, build_update_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]] @@ -68,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 @@ -259,9 +84,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -289,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" @@ -352,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -411,16 +243,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ElasticPool") @@ -586,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -651,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -715,9 +541,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -779,16 +603,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ElasticPoolUpdate") @@ -951,9 +773,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1015,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1079,9 +897,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 865a9136621e..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_revalidate_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]] @@ -83,9 +80,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -112,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" @@ -180,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -239,16 +243,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "EncryptionProtector") @@ -414,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -480,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -549,9 +547,7 @@ async def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 ab6a50c0ef77..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._endpoint_certificates_operations import build_get_request, build_list_by_instance_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]] @@ -76,9 +72,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -105,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" @@ -169,9 +174,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 7a8ca6e374f6..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -84,9 +86,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -114,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" @@ -181,9 +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: Literal["2021-11-01-preview"] = 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( @@ -334,16 +343,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedDatabaseBlobAuditingPolicy") 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 519b8f39f572..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -84,9 +86,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -113,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" @@ -178,9 +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: Literal["2021-11-01-preview"] = 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( @@ -237,16 +246,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") @@ -413,9 +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: Literal["2021-11-01-preview"] = 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 a451c8fd648d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,13 +38,10 @@ build_force_failover_allow_data_loss_request, build_get_request, build_list_by_server_request, + build_try_planned_before_forced_failover_request, build_update_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]] @@ -67,6 +65,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.FailoverGroup"]: + """Lists the failover groups 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 containing the failover group. 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 FailoverGroup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.FailoverGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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("FailoverGroupListResult", 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}/failoverGroups" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any @@ -96,9 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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( @@ -155,16 +242,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "FailoverGroup") @@ -330,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -392,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -456,9 +537,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -518,16 +597,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "FailoverGroupUpdate") @@ -690,9 +767,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -738,88 +813,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.FailoverGroup"]: - """Lists the failover groups 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 containing the failover group. 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 FailoverGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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("FailoverGroupListResult", 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}/failoverGroups" - } - async def _failover_initial( self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any ) -> Optional[_models.FailoverGroup]: @@ -834,9 +827,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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.FailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -905,9 +896,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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) @@ -964,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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.FailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -1036,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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) @@ -1080,3 +1065,136 @@ def get_long_running_output(pipeline_response): begin_force_failover_allow_data_loss.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss" } + + async def _try_planned_before_forced_failover_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Optional[_models.FailoverGroup]: + 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.FailoverGroup]] = kwargs.pop("cls", None) + + request = build_try_planned_before_forced_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._try_planned_before_forced_failover_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 + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("FailoverGroup", 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 + + _try_planned_before_forced_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover" + } + + @distributed_trace_async + async def begin_try_planned_before_forced_failover( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.FailoverGroup]: + """Fails over from the current primary server to this server. This operation tries planned before + forced failover but might still result in data loss. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either FailoverGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.FailoverGroup] = 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._try_planned_before_forced_failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_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): + deserialized = self._deserialize("FailoverGroup", 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_try_planned_before_forced_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover" + } 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 bbb3fc8fd00c..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -36,10 +37,6 @@ build_replace_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]] @@ -63,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, @@ -89,138 +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: Literal["2020-11-01-preview"] = 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 = { @@ -234,30 +239,27 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 _content = None - if isinstance(parameters, (IO, bytes)): + 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, ) @@ -271,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. @@ -304,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 = { @@ -319,18 +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: Literal["2020-11-01-preview"] = 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, ) @@ -344,174 +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: Literal["2020-11-01-preview"] = 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 = { @@ -525,29 +459,28 @@ async def replace( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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 _content = None - if isinstance(parameters, (IO, bytes)): + 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, ) @@ -561,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 2bad7107fed4..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,13 +32,9 @@ from ...operations._geo_backup_policies_operations import ( build_create_or_update_request, build_get_request, - build_list_by_database_request, + build_list_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]] @@ -61,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, @@ -73,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. @@ -82,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. @@ -108,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. @@ -117,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. @@ -141,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. @@ -150,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. @@ -174,14 +344,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GeoBackupPolicy") @@ -228,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 6df6edda98f4..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -39,10 +40,6 @@ build_list_by_location_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]] @@ -86,9 +83,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -115,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" @@ -178,9 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -237,16 +241,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstanceFailoverGroup") @@ -412,9 +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: Literal["2022-05-01-preview"] = 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) @@ -474,9 +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: Literal["2022-05-01-preview"] = 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( @@ -538,9 +536,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -595,9 +591,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -666,9 +660,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -725,9 +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: Literal["2022-05-01-preview"] = 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( @@ -797,9 +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: Literal["2022-05-01-preview"] = 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 788d9354ca56..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -39,10 +40,6 @@ build_update_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]] @@ -66,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. @@ -91,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -148,16 +309,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstancePool") @@ -313,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -374,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -435,9 +590,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -495,16 +648,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstancePoolUpdate") @@ -657,9 +808,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -703,151 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 51db6b158d75..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_server_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]] @@ -81,9 +78,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -110,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" @@ -173,9 +179,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -317,16 +321,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "IPv6FirewallRule") @@ -402,9 +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: Literal["2021-11-01-preview"] = 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( 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 93a36076ee21..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -38,10 +39,6 @@ build_update_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]] @@ -84,9 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -113,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,9 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -235,16 +239,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobAgent") @@ -410,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -472,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -536,9 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -598,16 +594,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobAgentUpdate") @@ -770,9 +764,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 c0116ac64c3c..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_agent_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]] @@ -83,9 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -113,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" @@ -178,9 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -330,16 +334,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobCredential") @@ -418,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 fa7f64e7457b..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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys 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 ( @@ -40,10 +40,6 @@ build_list_by_job_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]] @@ -118,9 +114,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -155,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" @@ -189,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, @@ -198,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. @@ -210,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 = { @@ -228,12 +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: Literal["2020-11-01-preview"] = 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, @@ -241,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, ) @@ -259,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, @@ -280,19 +428,18 @@ async def _create_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -306,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) @@ -314,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. @@ -338,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 @@ -354,19 +512,18 @@ async def begin_create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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, @@ -396,138 +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: Literal["2020-11-01-preview"] = 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, @@ -535,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. @@ -547,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 = { @@ -565,12 +596,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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, @@ -578,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, ) @@ -596,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, @@ -627,20 +646,17 @@ async def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -654,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) @@ -662,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. @@ -695,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 @@ -713,20 +718,17 @@ async def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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, @@ -756,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 4c1c56dfbedc..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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys 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 ( @@ -31,10 +31,6 @@ from ..._vendor import _convert_request from ...operations._job_step_executions_operations import build_get_request, build_list_by_job_execution_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]] @@ -115,9 +111,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -154,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" @@ -230,9 +235,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 aafe5afda201..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_version_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]] @@ -64,188 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 @@ -269,9 +84,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -300,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" @@ -373,9 +197,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -535,16 +357,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobStep") @@ -632,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -669,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 6710782d64ee..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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys 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 ( @@ -35,10 +35,6 @@ build_list_by_step_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]] @@ -63,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, @@ -79,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. @@ -92,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 @@ -119,9 +118,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -135,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, @@ -150,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, ) @@ -158,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" @@ -188,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, @@ -201,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, @@ -210,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. @@ -223,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 @@ -252,9 +345,7 @@ def list_by_step( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -268,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, @@ -284,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, ) @@ -292,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" @@ -322,95 +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: Literal["2020-11-01-preview"] = 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 29579d388ca8..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_agent_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]] @@ -83,9 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -113,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" @@ -178,9 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -330,16 +334,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobTargetGroup") @@ -418,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 a486c0b1a245..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._job_versions_operations import build_get_request, build_list_by_job_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]] @@ -80,9 +76,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -111,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" @@ -184,9 +189,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 7bf28b2c1506..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_agent_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]] @@ -83,9 +80,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -113,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" @@ -178,9 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -329,16 +333,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Job") @@ -417,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 f77f516b04bd..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ 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]] @@ -64,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, @@ -100,9 +191,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -161,16 +250,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LedgerDigestUploads") @@ -345,9 +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: Literal["2021-02-01-preview"] = 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) @@ -394,91 +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: Literal["2021-02-01-preview"] = 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, @@ -498,9 +498,7 @@ async def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -578,9 +576,7 @@ async def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 259d98d17514..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -47,10 +48,6 @@ build_update_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]] @@ -74,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, @@ -91,119 +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: Literal["2021-05-01-preview"] = 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, (IO, 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 @@ -211,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 @@ -253,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 @@ -267,32 +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: Literal["2021-05-01-preview"] = 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, @@ -300,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)) @@ -321,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 = { @@ -345,21 +607,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + 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, @@ -369,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, ) @@ -396,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 @@ -422,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 @@ -443,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, @@ -454,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 @@ -464,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". @@ -485,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 @@ -504,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 @@ -527,16 +787,14 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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, @@ -572,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, @@ -608,22 +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: Literal["2021-05-01-preview"] = 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, ) @@ -637,87 +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: Literal["2021-05-01-preview"] = 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 @@ -727,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 @@ -735,27 +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: Literal["2021-05-01-preview"] = 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, @@ -763,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)) @@ -782,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 @@ -819,9 +1112,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -835,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, ) @@ -851,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" @@ -881,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 @@ -912,9 +1220,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -928,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, ) @@ -942,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" @@ -972,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 @@ -1006,9 +1332,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -1022,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, ) @@ -1037,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" @@ -1067,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, @@ -1089,24 +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: Literal["2021-05-01-preview"] = 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, (IO, 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, @@ -1114,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, ) @@ -1131,83 +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( + 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 = await 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_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: IO, - *, - content_type: str = "application/json", **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. @@ -1220,11 +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. 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 @@ -1233,78 +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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @distributed_trace_async - 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.CopyLongTermRetentionBackupParameters, IO], - **kwargs: Any - ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: - """Copy an existing long term retention backup to a different server. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. Required. - :type resource_group_name: str - :param location_name: The location of the database. Required. - :type location_name: str - :param long_term_retention_server_name: The name of the server. Required. - :type long_term_retention_server_name: str - :param long_term_retention_database_name: The name of the database. Required. - :type long_term_retention_database_name: str - :param backup_name: The backup name. Required. - :type backup_name: str - :param parameters: The parameters needed for long term retention copy request. Is either a - CopyLongTermRetentionBackupParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.CopyLongTermRetentionBackupParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either - LongTermRetentionBackupOperationResult or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-05-01-preview"] = 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, @@ -1312,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)) @@ -1333,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 = { @@ -1358,21 +1645,19 @@ 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: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + 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, @@ -1383,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, ) @@ -1410,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. @@ -1440,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 @@ -1461,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, @@ -1473,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. @@ -1486,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". @@ -1507,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. @@ -1530,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 @@ -1553,16 +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: Literal["2021-05-01-preview"] = 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, @@ -1599,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, @@ -1639,15 +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: Literal["2021-05-01-preview"] = 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, @@ -1655,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, ) @@ -1669,90 +1944,83 @@ 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}" + _update_by_resource_group_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}/update" } - async def _delete_by_resource_group_initial( # pylint: disable=inconsistent-return-statements + @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 - ) -> 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: Literal["2021-05-01-preview"] = 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, {}) + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. - _delete_by_resource_group_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionDatabases/{longTermRetentionDatabaseName}/longTermRetentionBackups/{backupName}" - } + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be 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_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: IO, + *, + 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. @@ -1765,6 +2033,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: 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 @@ -1773,28 +2046,76 @@ 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: Literal["2021-05-01-preview"] = 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, + @distributed_trace_async + async def begin_update_by_resource_group( + self, + resource_group_name: str, + location_name: str, + long_term_retention_server_name: str, + long_term_retention_database_name: str, + backup_name: str, + parameters: Union[_models.UpdateLongTermRetentionBackupParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.LongTermRetentionBackupOperationResult]: + """Updates an existing long term retention backup. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param location_name: The location of the database. Required. + :type location_name: str + :param long_term_retention_server_name: The name of the server. Required. + :type long_term_retention_server_name: str + :param long_term_retention_database_name: The name of the database. Required. + :type long_term_retention_database_name: str + :param backup_name: The backup name. Required. + :type backup_name: str + :param parameters: The requested backup resource state. Is either a + UpdateLongTermRetentionBackupParameters type or a IO type. Required. + :type parameters: ~azure.mgmt.sql.models.UpdateLongTermRetentionBackupParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + LongTermRetentionBackupOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.LongTermRetentionBackupOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _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, @@ -1802,9 +2123,11 @@ async def begin_delete_by_resource_group( ) 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)) @@ -1821,306 +2144,6 @@ 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_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 - ) -> AsyncIterable["_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.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: Literal["2021-05-01-preview"] = 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 - :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: Literal["2021-05-01-preview"] = 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( - 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 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.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: Literal["2021-05-01-preview"] = 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 - - 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_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 85012505e418..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -43,10 +43,6 @@ build_list_by_resource_group_location_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]] @@ -70,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 @@ -100,9 +306,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -155,9 +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: Literal["2021-05-01-preview"] = 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( @@ -221,9 +423,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) @@ -266,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 @@ -299,9 +496,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -315,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, ) @@ -331,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" @@ -361,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 @@ -396,9 +602,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -412,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, ) @@ -427,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" @@ -457,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 @@ -489,9 +714,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -505,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, ) @@ -519,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" @@ -549,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 @@ -592,9 +829,7 @@ async def get_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -654,9 +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: Literal["2021-05-01-preview"] = 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( @@ -730,9 +963,7 @@ async def begin_delete_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) @@ -775,111 +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: Literal["2021-05-01-preview"] = 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, @@ -915,9 +1041,7 @@ def list_by_resource_group_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -947,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" @@ -980,100 +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: Literal["2021-05-01-preview"] = 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 59d9a4c5611f..761aa0da2df9 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_long_term_retention_policies_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ 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]] @@ -63,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, @@ -99,9 +191,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -160,16 +250,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LongTermRetentionPolicy") @@ -342,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -390,89 +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: Literal["2020-11-01-preview"] = 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 5f720f1dbfbd..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._maintenance_window_options_operations import 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]] @@ -92,9 +87,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 da338c0cfaf5..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._maintenance_windows_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]] @@ -91,9 +87,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -242,16 +236,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "MaintenanceWindows") 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 0effa797cb04..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_update_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]] @@ -64,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, @@ -100,9 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -161,16 +252,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -346,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -415,16 +502,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -600,9 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -648,90 +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: Literal["2020-11-01-preview"] = 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 5044e4f4f2e2..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ 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]] @@ -84,9 +81,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -114,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" @@ -186,9 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -344,16 +348,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseAdvancedThreatProtection") 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 5868dcaf0d54..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -34,10 +34,6 @@ build_list_by_table_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]] @@ -102,9 +98,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -137,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" @@ -206,9 +211,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -239,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" @@ -315,9 +329,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 a73c5644bc08..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_move_operations_operations import build_get_request, build_list_by_location_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]] @@ -89,9 +85,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -120,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" @@ -183,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 5c2b2a1e467d..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 @@ -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. # -------------------------------------------------------------------------- -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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_queries_operations import build_get_request, build_list_by_query_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]] @@ -88,9 +84,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -167,9 +161,7 @@ def list_by_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -201,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 f9bd6d46071f..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_recommended_sensitivity_labels_operations import build_update_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]] @@ -157,16 +153,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") 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 a40e9729daf4..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_restore_details_operations import 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]] @@ -91,9 +86,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 e416ff78f703..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_schemas_operations import build_get_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]] @@ -86,9 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -117,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" @@ -182,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 8a03d94c5eb1..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ 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]] @@ -61,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, @@ -80,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) @@ -98,9 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -161,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 @@ -196,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 @@ -229,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. @@ -253,16 +345,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseSecurityAlertPolicy") @@ -309,91 +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: Literal["2020-11-01-preview"] = 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 ae163aad96a0..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_security_events_operations import 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]] @@ -96,9 +92,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -130,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 d7dafd7c56c1..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -34,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, @@ -66,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, @@ -112,9 +485,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -295,16 +666,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabel") @@ -380,95 +749,9 @@ async def delete( # pylint: disable=inconsistent-return-statements :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: Literal["2020-11-01-preview"] = 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 - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Disables sensitivity recommendations on a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. + :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) @@ -486,13 +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: Literal["2020-11-01-preview"] = 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, @@ -502,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, ) @@ -523,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, @@ -538,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. @@ -574,12 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, @@ -589,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, ) @@ -610,184 +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: Literal["2020-11-01-preview"] = 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. @@ -796,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 @@ -814,33 +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: Literal["2020-11-01-preview"] = 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, (IO, 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, ) @@ -861,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"]: @@ -885,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 @@ -901,9 +1006,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -917,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, ) @@ -934,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" @@ -964,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 80cd58d73f50..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._managed_database_tables_operations import build_get_request, build_list_by_schema_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]] @@ -89,9 +85,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -121,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" @@ -194,9 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 636160cdeeda..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ 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]] @@ -61,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, @@ -98,9 +192,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -253,16 +345,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedTransparentDataEncryption") @@ -309,91 +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: Literal["2020-11-01-preview"] = 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 aa03c3f9f9ef..673c3b6636d0 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,10 +32,6 @@ 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]] @@ -69,7 +65,7 @@ async def get( rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Gets a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -90,8 +86,9 @@ async def get( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -105,10 +102,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -137,7 +132,7 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -157,11 +152,11 @@ async def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -182,13 +177,15 @@ async def create_or_update( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :type parameters: + ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ @@ -205,7 +202,7 @@ async def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -231,8 +228,9 @@ async def create_or_update( 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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ @@ -245,9 +243,9 @@ async def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated, IO], **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -268,14 +266,16 @@ async def create_or_update( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. Is either a - DatabaseVulnerabilityAssessmentRuleBaseline type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or IO + DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated type or a IO type. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated 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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -289,19 +289,17 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") + _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -333,7 +331,7 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -390,9 +388,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 481ad75ebad0..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -37,10 +37,6 @@ 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]] @@ -64,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, @@ -81,49 +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: Literal["2020-11-01-preview"] = 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, @@ -131,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. @@ -147,63 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( + 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, ) - 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) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + _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, - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + if response.status_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 @@ -246,9 +285,7 @@ async def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -292,42 +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: Literal["2020-11-01-preview"] = 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, @@ -336,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, @@ -397,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. @@ -413,59 +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: Literal["2020-11-01-preview"] = 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 69f242e74110..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ 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]] @@ -62,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, @@ -100,9 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -258,16 +350,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") @@ -353,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -389,91 +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: Literal["2020-11-01-preview"] = 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 292764db4794..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -43,10 +44,6 @@ build_update_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]] @@ -89,9 +86,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -118,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" @@ -181,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -240,16 +244,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabase") @@ -415,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -477,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -541,9 +539,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -603,16 +599,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseUpdate") @@ -775,9 +769,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -842,16 +834,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseMoveDefinition") @@ -1005,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1070,16 +1058,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseMoveDefinition") @@ -1233,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1298,16 +1282,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CompleteDatabaseRestoreDefinition") @@ -1463,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1528,16 +1508,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseStartMoveDefinition") @@ -1691,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1756,9 +1732,7 @@ def list_inaccessible_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -1785,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 306a6ed01d6d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_instance_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]] @@ -85,9 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -114,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" @@ -181,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -240,16 +244,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAdministrator") @@ -415,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -481,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -549,9 +547,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 e97970d29f5d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_instance_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]] @@ -84,9 +81,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -113,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" @@ -182,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -241,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAdvancedThreatProtection") @@ -422,9 +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: Literal["2022-02-01-preview"] = 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 271c989fdfe0..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_instance_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]] @@ -64,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, @@ -98,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -157,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAzureADOnlyAuthentication") @@ -344,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -410,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -479,9 +561,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -521,87 +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: Literal["2020-11-01-preview"] = 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 561e377fe259..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_managed_instance_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]] @@ -82,9 +79,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -111,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,9 +180,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -233,16 +237,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceDtc") @@ -403,9 +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: Literal["2022-05-01-preview"] = 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 b7b1deb30777..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_revalidate_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]] @@ -64,136 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 @@ -215,9 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -244,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" @@ -312,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -371,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceEncryptionProtector") @@ -549,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -596,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 9173d83e7b86..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_instance_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]] @@ -86,9 +83,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -116,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" @@ -179,9 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -238,16 +242,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceKey") @@ -416,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -478,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -542,9 +540,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 c7a078d3246e..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,14 +33,11 @@ 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, ) -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]] @@ -63,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, @@ -99,9 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -160,16 +252,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceLongTermRetentionPolicy") @@ -345,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -394,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. @@ -407,76 +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: Literal["2020-11-01-preview"] = 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 360d95fe669f..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -34,10 +34,6 @@ build_list_by_managed_instance_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]] @@ -82,9 +78,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -111,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" @@ -174,9 +179,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -243,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 630366fa8dc4..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_managed_instance_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]] @@ -64,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 @@ -93,9 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -152,16 +240,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstancePrivateEndpointConnection") @@ -327,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -389,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -453,9 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -495,87 +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: Literal["2020-11-01-preview"] = 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 c08d97e0dc78..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -33,10 +33,6 @@ build_list_by_managed_instance_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]] @@ -81,9 +77,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -110,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" @@ -173,9 +178,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 cf33015845c3..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._managed_instance_tde_certificates_operations import build_create_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]] @@ -75,16 +71,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TdeCertificate") @@ -228,9 +222,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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 be82325491d8..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_instance_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]] @@ -62,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, @@ -97,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -251,16 +340,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceVulnerabilityAssessment") @@ -342,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -377,88 +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: Literal["2020-11-01-preview"] = 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 87fc3f0fcf2e..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,15 +41,12 @@ 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, ) -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]] @@ -86,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -114,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" @@ -167,9 +174,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -197,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" @@ -250,9 +266,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -279,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" @@ -342,9 +367,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -400,16 +423,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstance") @@ -565,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -626,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -687,9 +704,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -747,16 +762,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceUpdate") @@ -909,9 +922,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -974,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1043,9 +1052,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1107,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -1136,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" @@ -1170,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, @@ -1184,10 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.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, ) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, @@ -1208,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" @@ -1222,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 @@ -1238,22 +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: Literal["2022-08-01-preview"] = 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, @@ -1264,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( @@ -1289,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, @@ -1303,10 +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: Literal["2022-08-01-preview"] = 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, @@ -1327,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" @@ -1341,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 @@ -1357,22 +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: Literal["2022-08-01-preview"] = 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, @@ -1383,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( @@ -1456,9 +1612,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -1492,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 3beef9efec9f..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ 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]] @@ -87,9 +84,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -117,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" @@ -187,9 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -248,16 +252,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedLedgerDigestUploads") @@ -436,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -504,9 +504,7 @@ async def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -584,9 +582,7 @@ async def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 12d4fa67bdce..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_update_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]] @@ -64,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, @@ -100,9 +193,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -161,16 +252,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -346,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -415,16 +502,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -600,9 +685,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -648,90 +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: Literal["2020-11-01-preview"] = 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 d2bca8f5b626..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -38,10 +39,6 @@ build_list_by_managed_instance_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]] @@ -85,9 +82,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -114,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" @@ -177,9 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -236,16 +240,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerDnsAliasCreation") @@ -410,9 +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: Literal["2021-11-01-preview"] = 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) @@ -472,9 +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: Literal["2021-11-01-preview"] = 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,9 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -598,16 +594,14 @@ async def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerDnsAliasAcquisition") @@ -769,9 +763,7 @@ async def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 bb94cc6c38a2..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_instance_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]] @@ -63,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. @@ -79,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 @@ -96,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -140,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]: @@ -155,16 +244,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerSecurityAlertPolicy") @@ -214,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", @@ -228,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. @@ -254,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", @@ -268,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. @@ -294,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]: @@ -306,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 @@ -330,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -377,87 +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: Literal["2020-11-01-preview"] = 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 af07e7a3855d..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_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]] @@ -68,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -94,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 a3e338ec7cd0..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. # -------------------------------------------------------------------------- -import sys -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 ( @@ -37,10 +37,6 @@ build_list_by_server_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]] @@ -64,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 @@ -93,9 +181,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -134,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, @@ -149,32 +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: Literal["2021-02-01-preview"] = 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, (IO, 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, @@ -209,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. @@ -305,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 @@ -323,13 +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: Literal["2021-02-01-preview"] = 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) @@ -339,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, @@ -388,9 +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: Literal["2021-02-01-preview"] = 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( @@ -452,9 +424,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) @@ -494,86 +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: Literal["2021-02-01-preview"] = 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 9287d43a0a94..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_server_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]] @@ -64,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.PrivateEndpointConnection"]: + """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 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 PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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("PrivateEndpointConnectionListResult", 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}/privateEndpointConnections" + } + @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -93,9 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-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( @@ -152,16 +240,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") @@ -323,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -385,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -449,9 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -491,87 +571,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """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 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 PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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("PrivateEndpointConnectionListResult", 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}/privateEndpointConnections" - } 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 b2b8536fc656..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_by_server_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]] @@ -76,9 +72,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -105,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" @@ -168,9 +173,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 324a65efdc5c..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._recommended_sensitivity_labels_operations import build_update_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]] @@ -157,16 +153,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") 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 7f735b557551..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._recoverable_databases_operations import build_get_request, build_list_by_server_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]] @@ -76,9 +72,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -105,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" @@ -179,9 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 a5b0f6900ca6..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._recoverable_managed_databases_operations import build_get_request, build_list_by_instance_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]] @@ -78,9 +74,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -107,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" @@ -170,9 +175,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 a0cefb285821..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -39,10 +39,6 @@ build_list_by_server_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]] @@ -87,9 +83,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -117,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" @@ -182,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -237,9 +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: Literal["2022-02-01-preview"] = 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( @@ -304,9 +305,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -362,9 +361,7 @@ async def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -436,9 +433,7 @@ async def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -496,9 +491,7 @@ async def _failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -570,9 +563,7 @@ async def begin_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -635,9 +626,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -664,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 6bea40586d12..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._restorable_dropped_databases_operations import build_get_request, build_list_by_server_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]] @@ -78,9 +74,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -107,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" @@ -181,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 03be6753c8fa..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -33,10 +33,6 @@ build_list_by_instance_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]] @@ -81,9 +77,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -110,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" @@ -173,9 +178,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 5ee569e27733..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ 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]] @@ -85,9 +82,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -115,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" @@ -168,16 +174,14 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CreateDatabaseRestorePointDefinition") @@ -343,9 +347,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -422,9 +424,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -494,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 8da6f181d4da..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -34,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, @@ -101,9 +104,7 @@ def list_current_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -134,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" @@ -269,16 +281,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") @@ -353,9 +363,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -386,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" @@ -420,179 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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, @@ -639,9 +485,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -822,16 +666,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabel") @@ -928,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -967,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 9fa785bd37e4..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_server_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]] @@ -84,9 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -113,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" @@ -182,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -241,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAdvancedThreatProtection") @@ -422,9 +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: Literal["2021-11-01-preview"] = 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 029758f95ea2..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,10 +32,6 @@ build_update_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]] @@ -88,9 +84,7 @@ async def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -157,9 +151,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -299,16 +291,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Advisor") 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 67e0dd5f7abf..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._server_automatic_tuning_operations import build_get_request, build_update_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]] @@ -80,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -212,16 +206,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAutomaticTuning") 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 72a4007fbbd3..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_server_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]] @@ -64,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, @@ -98,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -157,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAzureADAdministrator") @@ -335,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -401,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -470,9 +552,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -512,87 +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: Literal["2020-11-01-preview"] = 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 15d82872181d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_server_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]] @@ -64,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, @@ -98,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -157,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAzureADOnlyAuthentication") @@ -344,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -410,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -479,9 +561,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -521,87 +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: Literal["2020-11-01-preview"] = 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 d1b7b82fa4b0..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -84,9 +86,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -113,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" @@ -176,9 +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: Literal["2021-11-01-preview"] = 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( @@ -235,16 +244,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") @@ -408,9 +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: Literal["2021-11-01-preview"] = 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 2e6e69c70377..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_server_communication_links_operations.py +++ /dev/null @@ -1,511 +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. -# -------------------------------------------------------------------------- -import sys -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, -) - -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]] - - -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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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, (IO, 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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 eb99f15cdeb3..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_managed_instance_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]] @@ -84,9 +81,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -113,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" @@ -182,9 +188,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -241,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerConfigurationOption") @@ -417,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 6cb5eb3b4278..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_server_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]] @@ -63,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, @@ -96,9 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -155,16 +242,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerConnectionPolicy") @@ -327,9 +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: Literal["2021-05-01-preview"] = 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) @@ -374,86 +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: Literal["2021-05-01-preview"] = 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 f6acee5688fa..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_server_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]] @@ -84,9 +81,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -113,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" @@ -180,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -239,16 +243,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerDevOpsAuditingSettings") @@ -411,9 +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: Literal["2022-02-01-preview"] = 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 619ac91be843..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -38,10 +39,6 @@ build_list_by_server_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]] @@ -65,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 @@ -94,9 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -148,9 +234,7 @@ async def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -222,9 +306,7 @@ async def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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) @@ -281,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -345,9 +425,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -388,88 +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: Literal["2020-11-01-preview"] = 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, @@ -489,16 +485,14 @@ async def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerDnsAliasAcquisition") @@ -660,9 +654,7 @@ async def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 1e999d71f1ab..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_server_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]] @@ -83,9 +80,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -112,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" @@ -173,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -232,16 +236,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerKey") @@ -416,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -478,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -542,9 +540,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 56d54e46f239..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._server_operations_operations import build_list_by_server_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]] @@ -75,9 +71,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -104,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 109d0a624d78..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ build_list_by_server_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]] @@ -63,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. @@ -79,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 @@ -96,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -140,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]: @@ -155,16 +244,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") @@ -214,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", @@ -228,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. @@ -253,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", @@ -267,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. @@ -292,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]: @@ -304,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 @@ -327,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -374,87 +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: Literal["2020-11-01-preview"] = 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 ea8176da7a07..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_instance_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]] @@ -85,9 +82,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -114,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" @@ -177,9 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -236,16 +240,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerTrustCertificate") @@ -411,9 +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: Literal["2021-11-01-preview"] = 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) @@ -473,9 +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: Literal["2021-11-01-preview"] = 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( @@ -537,9 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 a2ab07b51a16..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -38,10 +39,6 @@ build_list_by_location_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]] @@ -65,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 @@ -94,9 +182,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -153,16 +239,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerTrustGroup") @@ -328,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -390,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -454,9 +534,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -497,88 +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: Literal["2020-11-01-preview"] = 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 @@ -598,9 +594,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -627,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 09c00df098dd..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._server_usages_operations import build_list_by_server_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]] @@ -60,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. @@ -75,7 +71,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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 = { @@ -102,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" @@ -113,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 949aa59bd887..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_server_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]] @@ -62,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, @@ -97,9 +187,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -251,16 +339,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") @@ -342,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -377,87 +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: Literal["2020-11-01-preview"] = 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 7d53ebe39ea8..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -42,10 +43,6 @@ build_update_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]] @@ -131,16 +128,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") @@ -194,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -222,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" @@ -273,9 +277,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -302,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" @@ -365,9 +378,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -419,16 +430,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Server") @@ -580,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -641,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -700,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -756,16 +759,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerUpdate") @@ -914,9 +915,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -979,16 +978,14 @@ async def _import_database_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ImportNewDatabaseDefinition") @@ -1141,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1202,9 +1197,7 @@ async def _refresh_status_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1271,9 +1264,7 @@ async def begin_refresh_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 7975c3a2284a..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_service_objectives_operations.py +++ /dev/null @@ -1,205 +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. -# -------------------------------------------------------------------------- -import sys -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 - -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]] - - -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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 1669eacc072f..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from ..._vendor import _convert_request from ...operations._sql_agent_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]] @@ -82,9 +78,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -213,16 +207,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlAgentConfiguration") 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 79579d7ba2a6..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,9 +95,7 @@ def list_by_sql_vulnerability_assessment( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -125,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" @@ -204,9 +214,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 d04336316471..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 @@ -6,6 +6,7 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -183,16 +184,14 @@ async def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") 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 f39d136fe996..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,9 +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: Literal["2022-02-01-preview"] = 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_execute_request( @@ -154,9 +152,7 @@ async def begin_execute( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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) 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 eb1985dd00eb..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 @@ -6,8 +6,10 @@ # 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 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 ( @@ -98,9 +100,7 @@ def list_by_baseline( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -130,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" @@ -212,9 +223,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -391,16 +400,14 @@ async def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") 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 a39256079f8b..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,9 +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: Literal["2022-02-01-preview"] = 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( 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 d17dbd4668bd..f9d6e9a38c67 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,9 +100,7 @@ def list_by_scan( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -131,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" @@ -213,9 +223,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 f2a507e10a5a..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,9 +95,7 @@ def list_by_sql_vulnerability_assessments( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -125,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,9 +212,7 @@ async def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 742c3114b3ad..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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._sql_vulnerability_assessments_operations import build_delete_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]] @@ -89,9 +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: Literal["2022-02-01-preview"] = 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( 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 cdb5b63b1c08..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -34,10 +35,6 @@ build_list_by_server_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]] @@ -82,9 +79,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -111,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" @@ -180,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -325,16 +329,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlVulnerabilityAssessment") 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 9f0e30bc9fa5..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -35,10 +36,6 @@ build_list_by_instance_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]] @@ -83,9 +80,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -112,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" @@ -180,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -325,16 +329,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "StartStopManagedInstanceSchedule") @@ -415,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 ea5e69554ab4..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._subscription_usages_operations import build_get_request, build_list_by_location_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]] @@ -71,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -99,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" @@ -157,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 328df999a34e..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._synapse_link_workspaces_operations import 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]] @@ -78,9 +74,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -108,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 8bb01d52dd5d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -39,10 +40,6 @@ build_list_linked_databases_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]] @@ -66,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 @@ -95,9 +183,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -154,16 +240,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncAgent") @@ -329,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -391,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -455,9 +535,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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,88 +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: Literal["2020-11-01-preview"] = 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 @@ -609,9 +605,7 @@ async def generate_key( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -671,9 +665,7 @@ def list_linked_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -701,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 b0dc5a701da4..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -44,10 +45,6 @@ build_update_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]] @@ -89,9 +86,7 @@ def list_sync_database_ids( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -117,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" @@ -151,136 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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. @@ -289,22 +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: Literal["2020-11-01-preview"] = 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, @@ -317,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, ) @@ -332,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 @@ -362,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. @@ -390,30 +266,70 @@ 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: """ + 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + 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 ) - cls: ClsType[_models.SyncGroupLogListResult] = kwargs.pop("cls", None) + response = pipeline_response.http_response + + if response.status_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) + + 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}" + } + + async 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, @@ -422,106 +338,32 @@ def list_logs( } 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_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 - - 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" - } - - @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", 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) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - 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, "SyncGroup") - request = build_cancel_sync_request( + 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, - template_url=self.cancel_sync.metadata["url"], + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -535,22 +377,121 @@ async def cancel_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, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("SyncGroup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SyncGroup", pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - cancel_sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync" + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } + @overload + async def begin_create_or_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 + ) -> AsyncLROPoller[_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. + :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 AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async 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 + ) -> AsyncLROPoller[_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. + :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 AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @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. + async 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 + ) -> AsyncLROPoller[_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. @@ -561,11 +502,78 @@ async def trigger_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 AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] :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.SyncGroup] = 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, + 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) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SyncGroup", 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}/databases/{databaseName}/syncGroups/{syncGroupName}" + } + + async 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: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -577,19 +585,17 @@ async def trigger_sync( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -603,22 +609,22 @@ async 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_async - async def get( + async 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. + ) -> AsyncLROPoller[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. @@ -630,63 +636,63 @@ async 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 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: Literal["2020-11-01-preview"] = 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) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + server_name=server_name, + 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: 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 = { + begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - async def _create_or_update_initial( + async def _update_initial( self, resource_group_name: str, server_name: str, @@ -706,21 +712,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, @@ -730,7 +734,7 @@ async 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, ) @@ -744,7 +748,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) @@ -752,20 +756,17 @@ async def _create_or_update_initial( if response.status_code == 200: deserialized = self._deserialize("SyncGroup", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("SyncGroup", pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) 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 - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, server_name: str, @@ -776,7 +777,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. @@ -807,7 +808,7 @@ async def begin_create_or_update( """ @overload - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, server_name: str, @@ -818,7 +819,7 @@ async def begin_create_or_update( content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. @@ -849,7 +850,7 @@ async def begin_create_or_update( """ @distributed_trace_async - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, server_name: str, @@ -858,7 +859,7 @@ async def begin_create_or_update( parameters: Union[_models.SyncGroup, IO], **kwargs: Any ) -> AsyncLROPoller[_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. @@ -891,16 +892,14 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) 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._update_initial( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -936,13 +935,30 @@ 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 = { + begin_update.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}" } - async def _delete_initial( # pylint: disable=inconsistent-return-statements + @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, @@ -954,19 +970,17 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -980,22 +994,22 @@ async 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_async - async def begin_delete( + @distributed_trace + def list_hub_schemas( self, resource_group_name: str, server_name: str, database_name: str, sync_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a sync group. + ) -> 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. @@ -1007,73 +1021,213 @@ async 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 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: 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: Literal["2020-11-01-preview"] = 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._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 + + async 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, AsyncList(list_of_elem) - 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, + 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 ) - return AsyncLROPoller(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 AsyncItemPaged(get_next, extract_data) + + list_hub_schemas.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas" } - async 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]: + ) -> 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, @@ -1082,34 +1236,20 @@ async 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: Literal["2020-11-01-preview"] = 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, (IO, 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, ) @@ -1127,114 +1267,18 @@ async 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 - async 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 - ) -> AsyncLROPoller[_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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async 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 - ) -> AsyncLROPoller[_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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async 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 - ) -> AsyncLROPoller[_models.SyncGroup]: - """Updates a sync group. + 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. @@ -1245,12 +1289,6 @@ async 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 AsyncARMPolling. Pass in False for @@ -1259,31 +1297,25 @@ async def begin_update( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either SyncGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.sql.models.SyncGroup] + :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: Literal["2020-11-01-preview"] = 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, 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._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, @@ -1291,11 +1323,9 @@ async 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: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1312,15 +1342,15 @@ 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}/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 - ) -> AsyncIterable["_models.SyncGroup"]: - """Lists sync groups under a hub database. + @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. @@ -1329,19 +1359,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: Literal["2020-11-01-preview"] = 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, @@ -1350,53 +1374,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 {}) - async 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, 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_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 + _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]: + 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/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/aio/operations/_sync_members_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/aio/operations/_sync_members_operations.py index 7c71977c112e..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +41,6 @@ build_update_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]] @@ -67,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, @@ -107,9 +201,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -170,16 +262,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncMember") @@ -368,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -438,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -515,9 +601,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -581,16 +665,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncMember") @@ -776,9 +858,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -826,194 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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, @@ -1034,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -1111,9 +1001,7 @@ async def begin_refresh_member_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -1155,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 b137e9469083..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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._tde_certificates_operations import build_create_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]] @@ -71,16 +67,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TdeCertificate") @@ -220,9 +214,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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 66628f639b22..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._time_zones_operations import build_get_request, build_list_by_location_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]] @@ -71,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -99,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" @@ -157,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 d320b7348fa9..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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,10 +37,6 @@ 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]] @@ -87,9 +84,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -117,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" @@ -188,9 +194,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -249,16 +253,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LogicalDatabaseTransparentDataEncryption") @@ -440,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 0820c3dc98fb..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 @@ -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. # -------------------------------------------------------------------------- -import sys 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 ( @@ -29,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_instance_pool_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]] @@ -78,9 +74,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -108,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 44f2fac1937e..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -39,10 +40,6 @@ build_update_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]] @@ -78,9 +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: Literal["2022-05-01-preview"] = 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 = { @@ -105,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" @@ -154,9 +160,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -182,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" @@ -241,9 +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: Literal["2022-05-01-preview"] = 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( @@ -294,9 +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: Literal["2022-05-01-preview"] = 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( @@ -355,9 +366,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -415,16 +424,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualClusterUpdate") @@ -577,9 +584,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -638,9 +643,7 @@ async def _update_dns_servers_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -708,9 +711,7 @@ async def begin_update_dns_servers( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 f033e2128f0d..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_server_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]] @@ -64,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 @@ -93,9 +181,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -152,16 +238,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualNetworkRule") @@ -327,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -389,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -453,9 +533,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -495,85 +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: Literal["2020-11-01-preview"] = 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 5755e1ed946c..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ build_list_by_workload_group_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]] @@ -64,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, @@ -104,9 +199,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -167,16 +260,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadClassifier") @@ -368,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -438,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -515,9 +602,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -559,92 +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: Literal["2020-11-01-preview"] = 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 6cd9e80dfcab..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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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 ( @@ -37,10 +38,6 @@ 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]] @@ -64,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 @@ -95,9 +186,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -156,16 +245,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadGroup") @@ -341,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -404,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -471,9 +554,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -514,88 +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: Literal["2020-11-01-preview"] = 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 2a17373ff534..4b25fc944810 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 @@ -60,18 +60,16 @@ from ._models_py3 import DatabaseVulnerabilityAssessment from ._models_py3 import DatabaseVulnerabilityAssessmentListResult from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaseline +from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated from ._models_py3 import DatabaseVulnerabilityAssessmentRuleBaselineItem from ._models_py3 import DatabaseVulnerabilityAssessmentScansExport from ._models_py3 import DeletedServer from ._models_py3 import DeletedServerListResult from ._models_py3 import DistributedAvailabilityGroup +from ._models_py3 import DistributedAvailabilityGroupSetRole from ._models_py3 import DistributedAvailabilityGroupsListResult from ._models_py3 import EditionCapability from ._models_py3 import ElasticPool -from ._models_py3 import ElasticPoolActivity -from ._models_py3 import ElasticPoolActivityListResult -from ._models_py3 import ElasticPoolDatabaseActivity -from ._models_py3 import ElasticPoolDatabaseActivityListResult from ._models_py3 import ElasticPoolEditionCapability from ._models_py3 import ElasticPoolListResult from ._models_py3 import ElasticPoolOperation @@ -87,6 +85,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 @@ -229,21 +230,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 NetworkSecurityPerimeterConfiguration +from ._models_py3 import NetworkSecurityPerimeterConfigurationListResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay -from ._models_py3 import OperationImpact from ._models_py3 import OperationListResult from ._models_py3 import OutboundEnvironmentEndpoint from ._models_py3 import OutboundEnvironmentEndpointCollection @@ -252,6 +256,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 @@ -282,6 +287,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 @@ -312,8 +318,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 @@ -342,12 +346,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 @@ -393,7 +394,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 @@ -442,6 +443,7 @@ 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,10 +464,13 @@ from ._sql_management_client_enums import FailoverGroupReplicationRole 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 @@ -484,7 +489,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 @@ -498,7 +502,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 @@ -518,6 +522,7 @@ 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 @@ -526,6 +531,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 @@ -539,13 +545,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 @@ -559,9 +565,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 @@ -626,18 +629,16 @@ "DatabaseVulnerabilityAssessment", "DatabaseVulnerabilityAssessmentListResult", "DatabaseVulnerabilityAssessmentRuleBaseline", + "DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated", "DatabaseVulnerabilityAssessmentRuleBaselineItem", "DatabaseVulnerabilityAssessmentScansExport", "DeletedServer", "DeletedServerListResult", "DistributedAvailabilityGroup", + "DistributedAvailabilityGroupSetRole", "DistributedAvailabilityGroupsListResult", "EditionCapability", "ElasticPool", - "ElasticPoolActivity", - "ElasticPoolActivityListResult", - "ElasticPoolDatabaseActivity", - "ElasticPoolDatabaseActivityListResult", "ElasticPoolEditionCapability", "ElasticPoolListResult", "ElasticPoolOperation", @@ -653,6 +654,9 @@ "EndpointCertificateListResult", "EndpointDependency", "EndpointDetail", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ExportDatabaseDefinition", "ExtendedDatabaseBlobAuditingPolicy", "ExtendedDatabaseBlobAuditingPolicyListResult", @@ -795,21 +799,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", + "NetworkSecurityPerimeterConfiguration", + "NetworkSecurityPerimeterConfigurationListResult", "Operation", "OperationDisplay", - "OperationImpact", "OperationListResult", "OutboundEnvironmentEndpoint", "OutboundEnvironmentEndpointCollection", @@ -818,6 +825,7 @@ "PartnerInfo", "PartnerRegionInfo", "PerformanceLevelCapability", + "PhaseDetails", "PrivateEndpointConnection", "PrivateEndpointConnectionListResult", "PrivateEndpointConnectionProperties", @@ -848,6 +856,7 @@ "RecoverableManagedDatabase", "RecoverableManagedDatabaseListResult", "RefreshExternalGovernanceStatusOperationResult", + "RefreshExternalGovernanceStatusOperationResultMI", "Remediation", "ReplicationLink", "ReplicationLinkListResult", @@ -878,8 +887,6 @@ "ServerAzureADOnlyAuthentication", "ServerBlobAuditingPolicy", "ServerBlobAuditingPolicyListResult", - "ServerCommunicationLink", - "ServerCommunicationLinkListResult", "ServerConfigurationOption", "ServerConfigurationOptionListResult", "ServerConnectionPolicy", @@ -908,12 +915,9 @@ "ServerVersionCapability", "ServerVulnerabilityAssessment", "ServerVulnerabilityAssessmentListResult", - "ServiceObjective", "ServiceObjectiveCapability", - "ServiceObjectiveListResult", "ServicePrincipal", "Sku", - "SloUsageMetric", "SqlAgentConfiguration", "SqlVulnerabilityAssessment", "SqlVulnerabilityAssessmentListResult", @@ -959,7 +963,7 @@ "UpdateLongTermRetentionBackupParameters", "UpdateVirtualClusterDnsServersOperation", "UpsertManagedServerOperationParameters", - "UpsertManagedServerOperationStep", + "UpsertManagedServerOperationStepWithEstimatesAndDuration", "Usage", "UsageListResult", "UserIdentity", @@ -1007,6 +1011,7 @@ "CreatedByType", "DNSRefreshOperationStatus", "DataMaskingFunction", + "DataMaskingPolicyName", "DataMaskingRuleState", "DataMaskingState", "DataWarehouseUserActivityName", @@ -1027,10 +1032,13 @@ "FailoverGroupReplicationRole", "GeoBackupPolicyName", "GeoBackupPolicyState", + "HybridSecondaryUsage", + "HybridSecondaryUsageDetected", "IdentityType", "ImplementationMethod", "InstanceFailoverGroupReplicationRole", "InstancePoolLicenseType", + "InstanceRole", "IsRetryable", "JobAgentState", "JobExecutionLifecycle", @@ -1049,7 +1057,6 @@ "ManagedInstanceAdministratorType", "ManagedInstanceLicenseType", "ManagedInstanceLongTermRetentionPolicyName", - "ManagedInstancePropertiesProvisioningState", "ManagedInstanceProxyOverride", "ManagedLedgerDigestUploadsName", "ManagedLedgerDigestUploadsState", @@ -1063,7 +1070,7 @@ "OperationOrigin", "PauseDelayTimeUnit", "PerformanceLevelUnit", - "PrimaryAggregationType", + "Phase", "PrincipalType", "PrivateEndpointProvisioningState", "PrivateLinkServiceConnectionStateActionsRequire", @@ -1083,6 +1090,7 @@ "ReplicationState", "RestoreDetailsName", "RestorePointType", + "RoleChangeType", "RuleSeverity", "RuleStatus", "RuleType", @@ -1091,6 +1099,7 @@ "SecondaryInstanceType", "SecondaryType", "SecurityAlertPolicyName", + "SecurityAlertPolicyNameAutoGenerated", "SecurityAlertPolicyState", "SecurityAlertsPolicyState", "SecurityEventType", @@ -1104,13 +1113,13 @@ "ServerPublicNetworkAccessFlag", "ServerTrustGroupPropertiesTrustScopesItem", "ServerWorkspaceFeature", - "ServiceObjectiveName", "ServicePrincipalType", "ShortTermRetentionPolicyName", "SqlAgentConfigurationPropertiesState", "SqlVulnerabilityAssessmentName", "SqlVulnerabilityAssessmentState", "StartStopScheduleName", + "Status", "StorageCapabilityStorageAccountType", "StorageKeyType", "SyncAgentState", @@ -1124,9 +1133,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 dfa1555a2f36..73d70704b639 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 @@ -1976,8 +1976,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. @@ -1987,15 +1987,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 = { @@ -2012,6 +2030,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__( @@ -2021,24 +2046,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): @@ -2189,6 +2247,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 = { @@ -2209,6 +2269,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 = { @@ -2229,6 +2290,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: @@ -2248,6 +2310,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): @@ -3396,11 +3459,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: @@ -3442,11 +3507,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: @@ -3534,6 +3601,53 @@ def __init__( self.baseline_results = baseline_results +class DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated(ProxyResource): + """A database vulnerability assessment rule baseline. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar baseline_results: The rule baseline result. + :vartype baseline_results: + list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "baseline_results": { + "key": "properties.baselineResults", + "type": "[DatabaseVulnerabilityAssessmentRuleBaselineItem]", + }, + } + + def __init__( + self, + *, + baseline_results: Optional[List["_models.DatabaseVulnerabilityAssessmentRuleBaselineItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword baseline_results: The rule baseline result. + :paramtype baseline_results: + list[~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineItem] + """ + super().__init__(**kwargs) + self.baseline_results = baseline_results + + class DatabaseVulnerabilityAssessmentRuleBaselineItem(_serialization.Model): """Properties for an Azure SQL Database Vulnerability Assessment rule baseline's result. @@ -3597,7 +3711,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. @@ -3609,10 +3723,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 @@ -3655,8 +3769,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. @@ -3673,7 +3787,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. @@ -3689,13 +3803,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 @@ -3703,6 +3815,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 @@ -3739,11 +3853,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"}, @@ -3755,11 +3869,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, @@ -3769,13 +3883,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 @@ -3783,6 +3895,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 @@ -3806,11 +3920,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 @@ -3820,23 +3934,31 @@ def __init__( class DataMaskingRuleListResult(_serialization.Model): - """The response to a list data masking rules request. + """The list of database data masking rules. - :ivar value: The list of database data masking rules. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of results. :vartype value: list[~azure.mgmt.sql.models.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): @@ -4000,7 +4122,7 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i :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" and "Sync". + 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. :vartype distributed_availability_group_id: str @@ -4012,6 +4134,8 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i :vartype link_state: str :ivar last_hardened_lsn: The last hardened lsn. :vartype last_hardened_lsn: str + :ivar instance_role: Role of managed instance. + :vartype instance_role: str """ _validation = { @@ -4023,6 +4147,7 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i "target_replica_id": {"readonly": True}, "link_state": {"readonly": True}, "last_hardened_lsn": {"readonly": True}, + "instance_role": {"readonly": True}, } _attribute_map = { @@ -4039,6 +4164,7 @@ class DistributedAvailabilityGroup(ProxyResource): # pylint: disable=too-many-i "target_replica_id": {"key": "properties.targetReplicaId", "type": "str"}, "link_state": {"key": "properties.linkState", "type": "str"}, "last_hardened_lsn": {"key": "properties.lastHardenedLsn", "type": "str"}, + "instance_role": {"key": "properties.instanceRole", "type": "str"}, } def __init__( @@ -4061,7 +4187,7 @@ def __init__( :keyword secondary_availability_group_name: The secondary availability group name. :paramtype secondary_availability_group_name: str :keyword replication_mode: The replication mode of a distributed availability group. Parameter - will be ignored during link creation. Known values are: "Async" and "Sync". + will be ignored during link creation. Known values are: "Async", "Sync", and "Async". :paramtype replication_mode: str or ~azure.mgmt.sql.models.ReplicationMode """ super().__init__(**kwargs) @@ -4075,6 +4201,50 @@ def __init__( self.target_replica_id = None self.link_state = None self.last_hardened_lsn = None + self.instance_role = 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): @@ -4123,6 +4293,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 @@ -4136,6 +4308,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}, } @@ -4148,6 +4321,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"}, } @@ -4163,6 +4337,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 @@ -4336,391 +4511,92 @@ 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 + :keyword reason: The reason for the capability not being available. + :paramtype reason: str """ super().__init__(**kwargs) - self.location = location - self.end_time = None - self.error_code = None - self.error_message = None - self.error_severity = None - self.operation = None - self.operation_id = None - self.percent_complete = None - self.requested_database_dtu_max = None - self.requested_database_dtu_min = None - self.requested_dtu = None - self.requested_elastic_pool_name = None - self.requested_storage_limit_in_gb = None - self.elastic_pool_name = None - self.server_name = None - self.start_time = None - self.state = None - self.requested_storage_limit_in_mb = None - self.requested_database_dtu_guarantee = None - self.requested_database_dtu_cap = None - self.requested_dtu_guarantee = None + self.name = None + self.supported_elastic_pool_performance_levels = None + self.zone_redundant = None + self.zone_pinning = None + self.status = None + self.reason = reason -class ElasticPoolActivityListResult(_serialization.Model): - """Represents the response to a list elastic pool activity request. +class ElasticPoolListResult(_serialization.Model): + """The result of an elastic pool list request. - 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 elastic pool activities. Required. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolActivity] + :ivar value: Array of results. + :vartype value: list[~azure.mgmt.sql.models.ElasticPool] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str """ _validation = { - "value": {"required": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolActivity]"}, + "value": {"key": "value", "type": "[ElasticPool]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - 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] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value + self.value = None + self.next_link = None -class ElasticPoolDatabaseActivity(ProxyResource): # pylint: disable=too-many-instance-attributes - """Represents the activity on an elastic pool. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: The geo-location where the resource lives. - :vartype location: str - :ivar database_name: The database name. - :vartype database_name: str - :ivar end_time: The time the operation finished (ISO8601 format). - :vartype end_time: ~datetime.datetime - :ivar error_code: The error code if available. - :vartype error_code: int - :ivar error_message: The error message if available. - :vartype error_message: str - :ivar error_severity: The error severity if available. - :vartype error_severity: int - :ivar operation: The operation name. - :vartype operation: str - :ivar operation_id: The unique operation ID. - :vartype operation_id: str - :ivar percent_complete: The percentage complete if available. - :vartype percent_complete: int - :ivar requested_elastic_pool_name: The name for the elastic pool the database is moving into if - available. - :vartype requested_elastic_pool_name: str - :ivar current_elastic_pool_name: The name of the current elastic pool the database is in if - available. - :vartype current_elastic_pool_name: str - :ivar current_service_objective: The name of the current service objective if available. - :vartype current_service_objective: str - :ivar requested_service_objective: The name of the requested service objective if available. - :vartype requested_service_objective: str - :ivar server_name: The name of the server the elastic pool is in. - :vartype server_name: str - :ivar start_time: The time the operation started (ISO8601 format). - :vartype start_time: ~datetime.datetime - :ivar state: The current state of the operation. - :vartype state: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "database_name": {"readonly": True}, - "end_time": {"readonly": True}, - "error_code": {"readonly": True}, - "error_message": {"readonly": True}, - "error_severity": {"readonly": True}, - "operation": {"readonly": True}, - "operation_id": {"readonly": True}, - "percent_complete": {"readonly": True}, - "requested_elastic_pool_name": {"readonly": True}, - "current_elastic_pool_name": {"readonly": True}, - "current_service_objective": {"readonly": True}, - "requested_service_objective": {"readonly": True}, - "server_name": {"readonly": True}, - "start_time": {"readonly": True}, - "state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "database_name": {"key": "properties.databaseName", "type": "str"}, - "end_time": {"key": "properties.endTime", "type": "iso-8601"}, - "error_code": {"key": "properties.errorCode", "type": "int"}, - "error_message": {"key": "properties.errorMessage", "type": "str"}, - "error_severity": {"key": "properties.errorSeverity", "type": "int"}, - "operation": {"key": "properties.operation", "type": "str"}, - "operation_id": {"key": "properties.operationId", "type": "str"}, - "percent_complete": {"key": "properties.percentComplete", "type": "int"}, - "requested_elastic_pool_name": {"key": "properties.requestedElasticPoolName", "type": "str"}, - "current_elastic_pool_name": {"key": "properties.currentElasticPoolName", "type": "str"}, - "current_service_objective": {"key": "properties.currentServiceObjective", "type": "str"}, - "requested_service_objective": {"key": "properties.requestedServiceObjective", "type": "str"}, - "server_name": {"key": "properties.serverName", "type": "str"}, - "start_time": {"key": "properties.startTime", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - } - - def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword location: The geo-location where the resource lives. - :paramtype location: str - """ - super().__init__(**kwargs) - self.location = location - self.database_name = None - self.end_time = None - self.error_code = None - self.error_message = None - self.error_severity = None - self.operation = None - self.operation_id = None - self.percent_complete = None - self.requested_elastic_pool_name = None - self.current_elastic_pool_name = None - self.current_service_objective = None - self.requested_service_objective = None - self.server_name = None - self.start_time = None - self.state = None - - -class ElasticPoolDatabaseActivityListResult(_serialization.Model): - """Represents the response to a list elastic pool database activity request. - - All required parameters must be populated in order to send to Azure. - - :ivar value: The list of elastic pool database activities. Required. - :vartype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPoolDatabaseActivity]"}, - } - - def __init__(self, *, value: List["_models.ElasticPoolDatabaseActivity"], **kwargs: Any) -> None: - """ - :keyword value: The list of elastic pool database activities. Required. - :paramtype value: list[~azure.mgmt.sql.models.ElasticPoolDatabaseActivity] - """ - super().__init__(**kwargs) - self.value = value - - -class ElasticPoolEditionCapability(_serialization.Model): - """The elastic pool edition capability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The elastic pool edition name. - :vartype name: str - :ivar supported_elastic_pool_performance_levels: The list of supported elastic pool DTU levels - for the edition. - :vartype supported_elastic_pool_performance_levels: - list[~azure.mgmt.sql.models.ElasticPoolPerformanceLevelCapability] - :ivar zone_redundant: Whether or not zone redundancy is supported for the edition. - :vartype zone_redundant: bool - :ivar status: The status of the capability. Known values are: "Visible", "Available", - "Default", and "Disabled". - :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus - :ivar reason: The reason for the capability not being available. - :vartype reason: str - """ - - _validation = { - "name": {"readonly": True}, - "supported_elastic_pool_performance_levels": {"readonly": True}, - "zone_redundant": {"readonly": True}, - "status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "supported_elastic_pool_performance_levels": { - "key": "supportedElasticPoolPerformanceLevels", - "type": "[ElasticPoolPerformanceLevelCapability]", - }, - "zone_redundant": {"key": "zoneRedundant", "type": "bool"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword reason: The reason for the capability not being available. - :paramtype reason: str - """ - super().__init__(**kwargs) - self.name = None - self.supported_elastic_pool_performance_levels = None - self.zone_redundant = None - self.status = None - self.reason = reason - - -class ElasticPoolListResult(_serialization.Model): - """The result of an elastic pool list request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~azure.mgmt.sql.models.ElasticPool] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ElasticPool]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ElasticPoolOperation(ProxyResource): # pylint: disable=too-many-instance-attributes - """A elastic pool operation. +class ElasticPoolOperation(ProxyResource): # pylint: disable=too-many-instance-attributes + """A elastic pool operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5397,6 +5273,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. @@ -6334,22 +6302,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): @@ -6412,6 +6390,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 = { @@ -6419,6 +6399,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__( @@ -6428,6 +6409,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: """ @@ -6439,12 +6421,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): @@ -6620,24 +6605,21 @@ def __init__(self, **kwargs: Any) -> None: class GeoBackupPolicy(ProxyResource): - """A database geo backup policy. + """A Geo backup policy. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID. :vartype id: str :ivar name: Resource name. :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. - :vartype kind: str :ivar location: Backup policy location. :vartype location: str - :ivar state: The state of the geo backup policy. Required. Known values are: "Disabled" and - "Enabled". + :ivar kind: Kind of geo backup policy. This is metadata used for the Azure portal experience. + :vartype kind: str + :ivar state: The state of the geo backup policy. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.sql.models.GeoBackupPolicyState :ivar storage_type: The storage type of the geo backup policy. :vartype storage_type: str @@ -6647,9 +6629,8 @@ class GeoBackupPolicy(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "kind": {"readonly": True}, "location": {"readonly": True}, - "state": {"required": True}, + "kind": {"readonly": True}, "storage_type": {"readonly": True}, } @@ -6657,43 +6638,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): @@ -6804,7 +6792,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. @@ -6829,6 +6817,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 = { @@ -6842,6 +6838,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 = { @@ -6855,6 +6854,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: @@ -6867,6 +6872,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 @@ -8049,8 +8057,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, @@ -8924,6 +8932,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 = { @@ -8951,12 +8961,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: """ @@ -8964,6 +8976,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 @@ -8974,6 +8988,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): @@ -10641,11 +10656,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. @@ -10656,6 +10669,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 @@ -10670,12 +10685,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. @@ -10737,6 +10769,11 @@ 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 """ _validation = { @@ -10747,9 +10784,12 @@ 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}, } _attribute_map = { @@ -10763,13 +10803,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"}, @@ -10792,6 +10837,8 @@ 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"}, } def __init__( # pylint: disable=too-many-locals @@ -10802,12 +10849,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, @@ -10844,6 +10895,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 @@ -10856,12 +10910,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 @@ -10920,13 +10986,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 @@ -10946,6 +11017,8 @@ 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 class ManagedInstanceAdministrator(ProxyResource): @@ -11391,6 +11464,8 @@ 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 @@ -11407,6 +11482,7 @@ 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}, @@ -11415,6 +11491,7 @@ class ManagedInstanceEditionCapability(_serialization.Model): _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"}, @@ -11429,6 +11506,7 @@ 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 @@ -12178,7 +12256,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 = { @@ -12190,7 +12269,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: @@ -12495,16 +12574,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: @@ -12512,6 +12595,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): @@ -12630,11 +12714,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. @@ -12645,6 +12727,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 @@ -12659,12 +12743,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. @@ -12726,15 +12827,23 @@ 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 """ _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}, } _attribute_map = { @@ -12744,13 +12853,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"}, @@ -12773,6 +12887,8 @@ 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"}, } def __init__( # pylint: disable=too-many-locals @@ -12782,12 +12898,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, @@ -12821,6 +12941,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 @@ -12833,12 +12956,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 @@ -12898,13 +13033,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 @@ -12924,9 +13064,11 @@ 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 -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. @@ -12939,6 +13081,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 @@ -12960,6 +13122,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}, @@ -12971,6 +13141,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": { @@ -12991,6 +13184,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 @@ -13552,6 +13753,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. @@ -13633,356 +13881,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 = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } + 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.value = value + self.localized_value = localized_value + + +class NetworkIsolationSettings(_serialization.Model): + """Contains the ARM resources for which to create private endpoint connection. + + :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 + """ + _attribute_map = { - "retention": {"key": "retention", "type": "str"}, - "time_grain": {"key": "timeGrain", "type": "str"}, + "storage_account_resource_id": {"key": "storageAccountResourceId", "type": "str"}, + "sql_server_resource_id": {"key": "sqlServerResourceId", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + storage_account_resource_id: Optional[str] = None, + sql_server_resource_id: Optional[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 + """ super().__init__(**kwargs) - self.retention = None - self.time_grain = None + self.storage_account_resource_id = storage_account_resource_id + self.sql_server_resource_id = sql_server_resource_id -class MetricDefinition(_serialization.Model): - """A database metric definition. +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """NSP Configuration for a server. 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] + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: + :vartype provisioning_state: str + :ivar network_security_perimeter: + :vartype network_security_perimeter: ~azure.mgmt.sql.models.NSPConfigPerimeter + :ivar resource_association: + :vartype resource_association: ~azure.mgmt.sql.models.NSPConfigAssociation + :ivar profile: + :vartype profile: ~azure.mgmt.sql.models.NSPConfigProfile + :ivar provisioning_issues: + :vartype provisioning_issues: list[~azure.mgmt.sql.models.NSPProvisioningIssue] """ _validation = { + "id": {"readonly": True}, "name": {"readonly": True}, - "primary_aggregation_type": {"readonly": True}, - "resource_uri": {"readonly": True}, - "unit": {"readonly": True}, - "metric_availabilities": {"readonly": True}, + "type": {"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]"}, + "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, **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 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.name = None - self.primary_aggregation_type = None - self.resource_uri = None - self.unit = None - self.metric_availabilities = None + 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 MetricDefinitionListResult(_serialization.Model): - """The response to a list database metric definitions request. +class NetworkSecurityPerimeterConfigurationListResult(_serialization.Model): + """A list of NSP configurations 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 metric definitions for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.MetricDefinition] + :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": {"required": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[MetricDefinition]"}, + "value": {"key": "value", "type": "[NetworkSecurityPerimeterConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: - """ - :keyword value: The list of metric definitions for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.MetricDefinition] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value - + self.value = None + self.next_link = None -class MetricListResult(_serialization.Model): - """The response to a list database metrics request. - All required parameters must be populated in order to send to Azure. +class NSPConfigAccessRule(_serialization.Model): + """NSPConfigAccessRule. - :ivar value: The list of metrics for the database. Required. - :vartype value: list[~azure.mgmt.sql.models.Metric] + :ivar name: + :vartype name: str + :ivar properties: + :vartype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties """ - _validation = { - "value": {"required": True}, - } - _attribute_map = { - "value": {"key": "value", "type": "[Metric]"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NSPConfigAccessRuleProperties"}, } - def __init__(self, *, value: List["_models.Metric"], **kwargs: Any) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPConfigAccessRuleProperties"] = None, + **kwargs: Any + ) -> None: """ - :keyword value: The list of metrics for the database. Required. - :paramtype value: list[~azure.mgmt.sql.models.Metric] + :keyword name: + :paramtype name: str + :keyword properties: + :paramtype properties: ~azure.mgmt.sql.models.NSPConfigAccessRuleProperties """ super().__init__(**kwargs) - self.value = value + self.name = name + self.properties = properties -class MetricName(_serialization.Model): - """A database metric name. +class NSPConfigAccessRuleProperties(_serialization.Model): + """NSPConfigAccessRuleProperties. - 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 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] """ - _validation = { - "value": {"readonly": True}, - "localized_value": {"readonly": True}, - } - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, + "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.value = None - self.localized_value = 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 MetricValue(_serialization.Model): - """Represents database metrics. - - Variables are only populated by the server, and will be ignored when sending a request. +class NSPConfigAssociation(_serialization.Model): + """NSPConfigAssociation. - :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 access_mode: + :vartype access_mode: str """ - _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"}, + "access_mode": {"key": "accessMode", "type": "str"}, } + def __init__(self, *, name: Optional[str] = None, access_mode: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: + :paramtype name: str + :keyword access_mode: + :paramtype access_mode: str + """ + super().__init__(**kwargs) + self.name = name + self.access_mode = access_mode + + +class NSPConfigNetworkSecurityPerimeterRule(_serialization.Model): + """NSPConfigNetworkSecurityPerimeterRule. + + :ivar id: + :vartype id: str + :ivar perimeter_guid: + :vartype perimeter_guid: str + :ivar location: + :vartype location: str + """ + _attribute_map = { - "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"}, + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, } - def __init__(self, **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 id: + :paramtype id: str + :keyword perimeter_guid: + :paramtype perimeter_guid: str + :keyword location: + :paramtype location: str + """ super().__init__(**kwargs) - self.count = None - self.average = None - self.maximum = None - self.minimum = None - self.timestamp = None - self.total = None - + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location -class MinCapacityCapability(_serialization.Model): - """The min capacity capability. - Variables are only populated by the server, and will be ignored when sending a request. +class NSPConfigPerimeter(_serialization.Model): + """NSPConfigPerimeter. - :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 + :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 NSPConfigProfile(_serialization.Model): + """NSPConfigProfile. + + :ivar name: + :vartype name: str + :ivar access_rules_version: + :vartype access_rules_version: str + :ivar access_rules: + :vartype access_rules: list[~azure.mgmt.sql.models.NSPConfigAccessRule] + """ + _attribute_map = { - "value": {"key": "value", "type": "float"}, - "status": {"key": "status", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "access_rules_version": {"key": "accessRulesVersion", "type": "str"}, + "access_rules": {"key": "accessRules", "type": "[NSPConfigAccessRule]"}, } - def __init__(self, *, reason: 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 reason: The reason for the capability not being available. - :paramtype reason: 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 = None - self.status = None - self.reason = reason + self.name = name + self.access_rules_version = access_rules_version + self.access_rules = access_rules -class Name(_serialization.Model): - """ARM Usage Name. +class NSPProvisioningIssue(_serialization.Model): + """NSPProvisioningIssue. - :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 properties: + :vartype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties """ _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "NSPProvisioningIssueProperties"}, } - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.NSPProvisioningIssueProperties"] = 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 properties: + :paramtype properties: ~azure.mgmt.sql.models.NSPProvisioningIssueProperties """ super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value + self.name = name + self.properties = properties -class NetworkIsolationSettings(_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): @@ -14046,58 +14460,20 @@ class OperationDisplay(_serialization.Model): "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): @@ -14348,6 +14724,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. @@ -14361,6 +14766,8 @@ class PrivateEndpointConnection(ProxyResource): :vartype type: str :ivar private_endpoint: Private endpoint which the connection belongs to. :vartype private_endpoint: ~azure.mgmt.sql.models.PrivateEndpointProperty + :ivar group_ids: Group IDs. + :vartype group_ids: list[str] :ivar private_link_service_connection_state: Connection state of the private endpoint connection. :vartype private_link_service_connection_state: @@ -14374,6 +14781,7 @@ class PrivateEndpointConnection(ProxyResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "group_ids": {"readonly": True}, "provisioning_state": {"readonly": True}, } @@ -14382,6 +14790,7 @@ class PrivateEndpointConnection(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "group_ids": {"key": "properties.groupIds", "type": "[str]"}, "private_link_service_connection_state": { "key": "properties.privateLinkServiceConnectionState", "type": "PrivateLinkServiceConnectionStateProperty", @@ -14406,6 +14815,7 @@ def __init__( """ super().__init__(**kwargs) self.private_endpoint = private_endpoint + self.group_ids = None self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None @@ -14999,13 +15409,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 @@ -15087,9 +15497,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"}, @@ -15657,6 +16067,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. @@ -15710,6 +16180,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", @@ -15740,6 +16212,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}, @@ -15757,6 +16230,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"}, @@ -15773,6 +16247,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 @@ -17432,78 +17907,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. @@ -18024,7 +18427,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 @@ -18072,7 +18476,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) @@ -18715,83 +19120,82 @@ def __init__( 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): @@ -18954,61 +19358,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. @@ -19039,6 +19388,8 @@ 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 status: The status of the capability. Known values are: "Visible", "Available", "Default", and "Disabled". :vartype status: str or ~azure.mgmt.sql.models.CapabilityStatus @@ -19059,6 +19410,7 @@ 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}, "status": {"readonly": True}, } @@ -19078,6 +19430,7 @@ class ServiceObjectiveCapability(_serialization.Model): # pylint: disable=too-m "key": "supportedMaintenanceConfigurations", "type": "[MaintenanceConfigurationCapability]", }, + "zone_pinning": {"key": "zonePinning", "type": "bool"}, "status": {"key": "status", "type": "str"}, "reason": {"key": "reason", "type": "str"}, } @@ -19100,36 +19453,11 @@ 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.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. @@ -19231,46 +19559,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. @@ -19488,6 +19776,8 @@ class SqlVulnerabilityAssessmentScanRecord(ProxyResource): # pylint: disable=to :vartype total_rules_count: int :ivar is_baseline_applied: Baseline created for this database, and has one or more rules. :vartype is_baseline_applied: bool + :ivar last_scan_time: The last scan time. + :vartype last_scan_time: ~datetime.datetime """ _validation = { @@ -19511,6 +19801,7 @@ class SqlVulnerabilityAssessmentScanRecord(ProxyResource): # pylint: disable=to "total_failed_rules_count": {"readonly": True}, "total_rules_count": {"readonly": True}, "is_baseline_applied": {"readonly": True}, + "last_scan_time": {"readonly": True}, } _attribute_map = { @@ -19534,6 +19825,7 @@ class SqlVulnerabilityAssessmentScanRecord(ProxyResource): # pylint: disable=to "total_failed_rules_count": {"key": "properties.totalFailedRulesCount", "type": "int"}, "total_rules_count": {"key": "properties.totalRulesCount", "type": "int"}, "is_baseline_applied": {"key": "properties.isBaselineApplied", "type": "bool"}, + "last_scan_time": {"key": "properties.lastScanTime", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: @@ -19556,6 +19848,7 @@ def __init__(self, **kwargs: Any) -> None: self.total_failed_rules_count = None self.total_rules_count = None self.is_baseline_applied = None + self.last_scan_time = None class SqlVulnerabilityAssessmentScanRecordListResult(_serialization.Model): @@ -19769,7 +20062,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", @@ -20985,7 +21278,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. @@ -21246,19 +21539,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"}, @@ -21267,21 +21569,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 2670cd53f424..ae0c3af94371 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 @@ -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" @@ -394,6 +394,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 +407,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): @@ -504,8 +510,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): @@ -544,6 +569,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. @@ -705,26 +737,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.""" @@ -803,9 +815,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): @@ -828,15 +843,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): @@ -972,6 +985,7 @@ class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): ASYNC = "Async" SYNC = "Sync" + ASYNC_ENUM = "Async" class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1013,6 +1027,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.""" @@ -1068,6 +1089,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" @@ -1178,76 +1205,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.""" @@ -1295,16 +1252,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" @@ -1412,39 +1381,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 d6642f431e59..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,67 +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 ( @@ -79,87 +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 ._servers_operations import ServersOperations 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 ._ipv6_firewall_rules_operations import IPv6FirewallRulesOperations -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 ._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 ._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 ._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,81 +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 ._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 ._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", @@ -252,69 +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", + "ServersOperations", "SqlAgentOperations", - "SubscriptionUsagesOperations", - "SyncAgentsOperations", - "SyncGroupsOperations", - "SyncMembersOperations", - "TdeCertificatesOperations", - "TimeZonesOperations", - "VirtualNetworkRulesOperations", - "WorkloadClassifiersOperations", - "WorkloadGroupsOperations", - "BackupShortTermRetentionPoliciesOperations", - "DatabaseExtensionsOperations", - "DatabaseOperationsOperations", - "DatabaseUsagesOperations", - "LedgerDigestUploadsOperations", - "OutboundFirewallRulesOperations", - "UsagesOperations", - "LongTermRetentionBackupsOperations", - "LongTermRetentionManagedInstanceBackupsOperations", - "RestorableDroppedManagedDatabasesOperations", - "ServerConnectionPoliciesOperations", - "DistributedAvailabilityGroupsOperations", - "ServerTrustCertificatesOperations", - "IPv6FirewallRulesOperations", - "EndpointCertificatesOperations", - "ManagedDatabaseSensitivityLabelsOperations", - "ManagedDatabaseRecommendedSensitivityLabelsOperations", - "SensitivityLabelsOperations", - "RecommendedSensitivityLabelsOperations", - "ServerBlobAuditingPoliciesOperations", - "DatabaseBlobAuditingPoliciesOperations", - "ExtendedDatabaseBlobAuditingPoliciesOperations", - "ExtendedServerBlobAuditingPoliciesOperations", - "DatabaseAdvancedThreatProtectionSettingsOperations", - "ServerAdvancedThreatProtectionSettingsOperations", - "ManagedServerDnsAliasesOperations", - "DatabaseSqlVulnerabilityAssessmentBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentExecuteScanOperations", - "DatabaseSqlVulnerabilityAssessmentRuleBaselinesOperations", - "DatabaseSqlVulnerabilityAssessmentScanResultOperations", - "DatabaseSqlVulnerabilityAssessmentScansOperations", - "DatabaseSqlVulnerabilityAssessmentsSettingsOperations", - "ManagedDatabaseAdvancedThreatProtectionSettingsOperations", - "ManagedInstanceAdvancedThreatProtectionSettingsOperations", - "ReplicationLinksOperations", "SqlVulnerabilityAssessmentBaselineOperations", "SqlVulnerabilityAssessmentBaselinesOperations", "SqlVulnerabilityAssessmentExecuteScanOperations", @@ -324,22 +320,20 @@ "SqlVulnerabilityAssessmentScansOperations", "SqlVulnerabilityAssessmentsSettingsOperations", "SqlVulnerabilityAssessmentsOperations", - "ManagedDatabaseMoveOperationsOperations", - "ManagedInstanceDtcsOperations", - "SynapseLinkWorkspacesOperations", - "VirtualClustersOperations", - "InstanceFailoverGroupsOperations", - "ManagedDatabaseRestoreDetailsOperations", - "DatabaseEncryptionProtectorsOperations", - "ManagedDatabasesOperations", - "ManagedInstancesOperations", - "ManagedLedgerDigestUploadsOperations", - "RecoverableDatabasesOperations", - "RestorableDroppedDatabasesOperations", - "ServerConfigurationOptionsOperations", - "ServersOperations", "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 bbaaeca45e9b..7113bae7f15e 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2021-02-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2021-02-01-preview"] = 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 @@ -118,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, @@ -136,9 +120,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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") @@ -165,29 +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: Literal["2021-02-01-preview"] = 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"), } @@ -197,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: @@ -221,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, @@ -257,9 +341,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -318,16 +400,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "BackupShortTermRetentionPolicy") @@ -500,9 +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: Literal["2021-02-01-preview"] = 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) @@ -569,16 +647,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "BackupShortTermRetentionPolicy") @@ -751,9 +827,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) @@ -799,89 +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: Literal["2021-02-01-preview"] = 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 10a3161dfdf2..51f510f3e52b 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -49,9 +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: Literal["2020-11-01-preview"] = 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,9 +117,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 067d0c400311..1a1b68a963e1 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -39,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: Literal["2014-04-01"] = 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 @@ -56,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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -69,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: Literal["2014-04-01"] = 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 @@ -92,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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -105,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: @@ -129,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", @@ -149,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 @@ -170,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", @@ -184,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 @@ -205,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: @@ -217,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 @@ -243,15 +323,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingPolicy") @@ -260,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, @@ -280,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: Literal["2014-04-01"] = 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 09ddc2f4ecfc..e0f9c5e2e5b9 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -76,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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -112,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: @@ -136,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, *, @@ -157,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. @@ -165,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 @@ -181,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, *, @@ -196,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. @@ -204,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 @@ -220,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 @@ -233,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 @@ -261,15 +365,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingRule") @@ -278,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, @@ -317,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: Literal["2014-04-01"] = 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 2ef4e60d5a9e..f90ea7c358bb 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -135,85 +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: Literal["2020-11-01-preview"] = 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 @@ -236,9 +149,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -266,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" @@ -299,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 85bce065479d..9cdafa723b9d 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2021-11-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -127,9 +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: Literal["2021-11-01-preview"] = 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") @@ -202,9 +193,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -232,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" @@ -304,9 +304,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -462,16 +460,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseAdvancedThreatProtection") 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 35b5b3105e75..2d51f946c740 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +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: Literal["2020-11-01-preview"] = 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,9 +86,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -132,9 +124,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -219,9 +209,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -291,9 +279,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -443,16 +429,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Advisor") 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 5fe9d7ce6481..97e3b29f88fb 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -45,9 +41,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +73,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -158,9 +150,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -300,16 +290,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseAutomaticTuning") 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 6274e95de4af..a8deea112233 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -46,9 +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: Literal["2021-11-01-preview"] = 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 @@ -81,9 +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: Literal["2021-11-01-preview"] = 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,9 +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: Literal["2021-11-01-preview"] = 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") @@ -190,9 +186,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -220,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" @@ -287,9 +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: Literal["2021-11-01-preview"] = 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( @@ -440,16 +443,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseBlobAuditingPolicy") 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 913a0116ca55..6bf4cb903d71 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -56,9 +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: Literal["2020-11-01-preview"] = 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 @@ -108,9 +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: Literal["2020-11-01-preview"] = 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,9 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -244,9 +234,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -279,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,9 +347,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -381,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" @@ -457,9 +465,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 588c21519057..a23f13d142e4 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +46,7 @@ def build_revalidate_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -85,9 +78,7 @@ def build_revert_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -147,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -220,9 +209,7 @@ def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -285,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -358,9 +343,7 @@ def begin_revert( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 fc8fe06f4845..cf837feb42f9 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,29 +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: Literal["2021-02-01-preview"] = 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"), } @@ -73,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, @@ -84,15 +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: Literal["2021-02-01-preview"] = 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", @@ -111,34 +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: Literal["2021-02-01-preview"] = 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"), } @@ -148,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: @@ -172,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 @@ -203,9 +290,7 @@ def get( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -260,16 +345,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseExtensions") @@ -327,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. @@ -370,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. @@ -411,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. @@ -445,9 +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: Literal["2021-02-01-preview"] = 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) @@ -493,90 +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: Literal["2021-02-01-preview"] = 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 23d71c240578..f8c1a5aee715 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,29 +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: Literal["2021-02-01-preview"] = 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"), } @@ -71,29 +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: Literal["2021-02-01-preview"] = 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"), } @@ -102,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: @@ -127,74 +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: Literal["2021-02-01-preview"] = 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 @@ -216,9 +140,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -246,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" @@ -279,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 878f7141f3b6..bb9854fe8508 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -50,9 +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: Literal["2020-11-01-preview"] = 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 @@ -91,9 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -133,9 +125,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -216,9 +206,7 @@ def list_by_database_advisor( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -296,9 +284,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -458,16 +444,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedAction") 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 7086f82e1d0f..bdce91c77a6f 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +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: Literal["2020-11-01-preview"] = 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,9 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -170,9 +162,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -201,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" @@ -266,9 +267,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 882d79d78e3b..7d590210073c 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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, @@ -91,10 +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: Literal["2020-11-01-preview"] = 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 @@ -116,33 +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: Literal["2020-11-01-preview"] = 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"), } @@ -152,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: @@ -176,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, @@ -195,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) @@ -213,9 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -276,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 @@ -311,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 @@ -344,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. @@ -368,16 +453,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSecurityAlertPolicy") @@ -424,90 +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: Literal["2020-11-01-preview"] = 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 cb4a0cd8e571..b8f3de9259da 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +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: Literal["2022-02-01-preview"] = 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 @@ -94,9 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -138,9 +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: Literal["2022-02-01-preview"] = 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") @@ -223,9 +214,7 @@ def list_by_sql_vulnerability_assessment( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -254,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" @@ -330,9 +330,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) request = build_get_request( @@ -497,16 +495,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") 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 b162e401c504..c98275041ec7 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +46,7 @@ def build_execute_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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", @@ -115,9 +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: Literal["2022-02-01-preview"] = 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_execute_request( @@ -188,9 +179,7 @@ def begin_execute( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) 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 29cde94baa97..456f2833d06d 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +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: Literal["2022-02-01-preview"] = 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 @@ -97,9 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -143,9 +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: Literal["2022-02-01-preview"] = 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") @@ -191,9 +182,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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", @@ -272,9 +261,7 @@ def list_by_baseline( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -304,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" @@ -383,9 +381,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -559,16 +555,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") @@ -657,9 +651,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( 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 77c01f747f15..7f820ef3d724 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +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: Literal["2022-02-01-preview"] = 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 @@ -97,9 +91,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -185,9 +177,7 @@ def list_by_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -217,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" @@ -296,9 +297,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 6ad92eb0c1ff..0e16be097a08 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +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: Literal["2022-02-01-preview"] = 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 @@ -94,9 +88,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -176,9 +168,7 @@ def list_by_sql_vulnerability_assessments( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -207,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" @@ -281,9 +282,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 1c9482756a9d..3e9a7189ea9a 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-02-01-preview"] = 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 @@ -85,9 +79,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -157,9 +149,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -187,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" @@ -259,9 +260,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.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 03585170b9db..d15a971a14ac 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -53,9 +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: Literal["2020-11-01-preview"] = 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,9 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -177,9 +169,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -209,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" @@ -282,9 +283,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 cb00e4530b71..fd0a08dafb06 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2021-02-01-preview"] = 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,9 +108,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -144,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 b185ac23e036..9aa74d7bd5a9 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -98,9 +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: Literal["2020-11-01-preview"] = 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") @@ -146,9 +138,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -239,9 +229,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -423,16 +411,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") @@ -524,9 +510,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 97e95674dc22..1df1630c6fd8 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,24 +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: Literal["2020-11-01-preview"] = 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"), @@ -68,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"), } @@ -77,29 +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: Literal["2020-11-01-preview"] = 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"), @@ -108,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"), } @@ -122,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, @@ -134,15 +132,13 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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"), @@ -163,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, @@ -175,18 +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: Literal["2020-11-01-preview"] = 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"), @@ -204,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: @@ -229,148 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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, @@ -401,9 +247,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -432,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" @@ -506,9 +361,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -588,9 +441,7 @@ def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -633,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 f31bdcd6d240..472c2fef575e 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2020-11-01-preview"] = 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 @@ -120,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, @@ -135,11 +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: Literal["2020-11-01-preview"] = 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", @@ -160,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -191,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: @@ -216,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, @@ -254,9 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -412,16 +495,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") @@ -507,9 +588,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -543,90 +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: Literal["2020-11-01-preview"] = 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 36c2a626a665..35abe269f6a0 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,80 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_list_metrics_request( - resource_group_name: str, server_name: str, database_name: str, subscription_id: str, *, filter: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_list_by_server_request( resource_group_name: str, server_name: str, subscription_id: str, *, skip_token: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -155,9 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -193,9 +121,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -229,9 +155,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -258,9 +182,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -295,9 +217,7 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -337,9 +257,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -368,9 +286,7 @@ def build_import_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -405,9 +321,7 @@ def build_rename_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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( @@ -439,9 +353,7 @@ def build_pause_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -473,9 +385,7 @@ def build_resume_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -506,9 +416,7 @@ def build_upgrade_data_warehouse_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -535,9 +443,7 @@ def build_list_by_elastic_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -569,9 +475,7 @@ def build_list_inaccessible_by_server_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -615,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 @@ -806,9 +540,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -836,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" @@ -910,9 +653,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) request = build_get_request( @@ -971,16 +712,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Database") @@ -1143,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1207,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1271,9 +1006,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1335,16 +1068,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseUpdate") @@ -1504,9 +1235,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1573,16 +1302,14 @@ def _export_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExportDatabaseDefinition") @@ -1745,9 +1472,7 @@ def begin_export( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1812,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1885,9 +1608,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1948,16 +1669,14 @@ def _import_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ImportExistingDatabaseDefinition") @@ -2120,9 +1839,7 @@ def begin_import_method( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -2270,16 +1987,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ResourceMoveDefinition") @@ -2332,9 +2047,7 @@ def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) request = build_pause_request( @@ -2402,9 +2115,7 @@ def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2461,9 +2172,7 @@ def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database]] = kwargs.pop("cls", None) request = build_resume_request( @@ -2531,9 +2240,7 @@ def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -2590,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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_upgrade_data_warehouse_request( @@ -2654,9 +2359,7 @@ def begin_upgrade_data_warehouse( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -2718,9 +2421,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2748,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" @@ -2801,9 +2513,7 @@ def list_inaccessible_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.DatabaseListResult] = kwargs.pop("cls", None) error_map = { @@ -2830,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 d57e930d960e..0119a3df104f 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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 @@ -68,23 +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: Literal["2020-11-01-preview"] = 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"), } @@ -99,22 +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: Literal["2020-11-01-preview"] = 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"), } @@ -135,9 +125,7 @@ def build_recover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -193,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -220,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" @@ -252,69 +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: Literal["2020-11-01-preview"] = 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. @@ -329,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -357,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" @@ -391,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]: @@ -405,9 +409,7 @@ def _recover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -472,9 +474,7 @@ def begin_recover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 b15455a9456f..3b638140e204 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2021-11-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -125,9 +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: Literal["2021-11-01-preview"] = 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") @@ -167,9 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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,9 +191,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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") @@ -235,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 = _format_url_section(_url, **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:: @@ -274,9 +302,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -303,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" @@ -370,9 +407,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -429,16 +464,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") @@ -604,9 +637,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -670,9 +701,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -738,9 +767,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -800,16 +827,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DistributedAvailabilityGroup") @@ -972,9 +997,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -1019,3 +1042,238 @@ 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, **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 d1eb0607654f..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_activities_operations.py +++ /dev/null @@ -1,176 +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. -# -------------------------------------------------------------------------- -import sys -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, _format_url_section - -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]] - -_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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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 d47ea2e89568..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_elastic_pool_database_activities_operations.py +++ /dev/null @@ -1,176 +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. -# -------------------------------------------------------------------------- -import sys -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, _format_url_section - -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]] - -_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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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 de5e3125c3d7..597348e6da88 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -71,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -102,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: @@ -127,74 +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: Literal["2020-11-01-preview"] = 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 @@ -217,9 +141,7 @@ def list_by_elastic_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -247,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" @@ -280,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 89aae80baa1a..29727b397afe 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,86 +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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2022-08-01-preview"] = 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 @@ -154,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -188,9 +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: Literal["2022-08-01-preview"] = 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") @@ -224,9 +144,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -253,9 +171,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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,9 +205,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -331,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 @@ -522,9 +266,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -552,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" @@ -615,9 +368,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -674,16 +425,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ElasticPool") @@ -849,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -913,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -977,9 +722,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1041,16 +784,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ElasticPoolUpdate") @@ -1213,9 +954,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1277,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1341,9 +1078,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 014406cd5aad..5d162ba01874 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2020-11-01-preview"] = 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,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -123,9 +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: Literal["2020-11-01-preview"] = 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") @@ -163,9 +154,7 @@ def build_revalidate_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -224,9 +213,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -253,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" @@ -321,9 +319,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -380,16 +376,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "EncryptionProtector") @@ -555,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -621,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -690,9 +680,7 @@ def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 d8a45325108e..fea49d0417ad 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2021-11-01-preview"] = 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,9 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -145,9 +137,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -174,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" @@ -238,9 +239,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 5ff129b7a268..1b52af010b35 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -46,9 +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: Literal["2021-11-01-preview"] = 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 @@ -81,9 +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: Literal["2021-11-01-preview"] = 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,9 +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: Literal["2021-11-01-preview"] = 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") @@ -190,9 +186,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -220,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" @@ -287,9 +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: Literal["2021-11-01-preview"] = 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( @@ -440,16 +443,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedDatabaseBlobAuditingPolicy") 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 b7d58b653c07..887540e5469e 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -48,9 +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: Literal["2021-11-01-preview"] = 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,9 +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: Literal["2021-11-01-preview"] = 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 @@ -115,9 +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: Literal["2021-11-01-preview"] = 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,9 +181,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -214,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" @@ -279,9 +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: Literal["2021-11-01-preview"] = 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( @@ -338,16 +341,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") @@ -511,9 +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: Literal["2021-11-01-preview"] = 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 9ceca6e74fdd..43eb95464dc6 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,15 +39,44 @@ _SERIALIZER.client_side_validation = False +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/failoverGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_get_request( resource_group_name: str, server_name: str, failover_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: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -118,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -147,9 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -178,25 +198,24 @@ def build_update_request( return HttpRequest(method="PATCH", 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_failover_request( + resource_group_name: str, server_name: str, failover_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: Literal["2020-11-01-preview"] = 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}/failoverGroups", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/failover", ) # 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"), + "failoverGroupName": _SERIALIZER.url("failover_group_name", failover_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -208,24 +227,22 @@ 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) -def build_failover_request( +def build_force_failover_allow_data_loss_request( resource_group_name: str, server_name: str, failover_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: Literal["2020-11-01-preview"] = 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}/failoverGroups/{failoverGroupName}/failover", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -245,21 +262,19 @@ def build_failover_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_force_failover_allow_data_loss_request( +def build_try_planned_before_forced_failover_request( resource_group_name: str, server_name: str, failover_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: Literal["2020-11-01-preview"] = 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}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -298,6 +313,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.FailoverGroup"]: + """Lists the failover groups 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 containing the failover group. 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 FailoverGroup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.FailoverGroupListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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("FailoverGroupListResult", 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}/failoverGroups" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any @@ -327,9 +433,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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( @@ -386,16 +490,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "FailoverGroup") @@ -561,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -623,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -687,9 +785,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -749,16 +845,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "FailoverGroupUpdate") @@ -921,9 +1015,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -969,88 +1061,6 @@ def get_long_running_output(pipeline_response): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}" } - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.FailoverGroup"]: - """Lists the failover groups 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 containing the failover group. 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 FailoverGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.FailoverGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.FailoverGroupListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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("FailoverGroupListResult", 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}/failoverGroups" - } - def _failover_initial( self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any ) -> Optional[_models.FailoverGroup]: @@ -1065,9 +1075,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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.FailoverGroup]] = kwargs.pop("cls", None) request = build_failover_request( @@ -1136,9 +1144,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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) @@ -1195,9 +1201,7 @@ def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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.FailoverGroup]] = kwargs.pop("cls", None) request = build_force_failover_allow_data_loss_request( @@ -1267,9 +1271,7 @@ def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-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) @@ -1311,3 +1313,136 @@ def get_long_running_output(pipeline_response): begin_force_failover_allow_data_loss.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/forceFailoverAllowDataLoss" } + + def _try_planned_before_forced_failover_initial( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> Optional[_models.FailoverGroup]: + 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.FailoverGroup]] = kwargs.pop("cls", None) + + request = build_try_planned_before_forced_failover_request( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._try_planned_before_forced_failover_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 + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("FailoverGroup", 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 + + _try_planned_before_forced_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover" + } + + @distributed_trace + def begin_try_planned_before_forced_failover( + self, resource_group_name: str, server_name: str, failover_group_name: str, **kwargs: Any + ) -> LROPoller[_models.FailoverGroup]: + """Fails over from the current primary server to this server. This operation tries planned before + forced failover but might still result in data loss. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param failover_group_name: The name of the failover group. Required. + :type failover_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either FailoverGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.FailoverGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.FailoverGroup] = 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._try_planned_before_forced_failover_initial( + resource_group_name=resource_group_name, + server_name=server_name, + failover_group_name=failover_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): + deserialized = self._deserialize("FailoverGroup", 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_try_planned_before_forced_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/failoverGroups/{failoverGroupName}/tryPlannedBeforeForcedFailover" + } 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 f2289fd21d59..050c3ba9908d 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -74,27 +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: Literal["2020-11-01-preview"] = 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"), } @@ -111,14 +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: Literal["2020-11-01-preview"] = 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", @@ -136,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -167,31 +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: Literal["2020-11-01-preview"] = 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"), } @@ -200,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: @@ -228,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, @@ -253,138 +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: Literal["2020-11-01-preview"] = 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 = { @@ -398,30 +393,27 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 _content = None - if isinstance(parameters, (IO, bytes)): + 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, ) @@ -435,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. @@ -468,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 = { @@ -483,18 +473,16 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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, ) @@ -508,174 +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: Literal["2020-11-01-preview"] = 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 = { @@ -689,29 +613,28 @@ def replace( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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 _content = None - if isinstance(parameters, (IO, bytes)): + 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, ) @@ -725,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 dd2b8fad5dce..787bf9156602 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -74,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( @@ -92,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: Literal["2014-04-01"] = 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 @@ -101,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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -119,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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -146,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: @@ -170,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, @@ -182,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. @@ -191,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. @@ -217,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. @@ -226,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. @@ -250,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. @@ -259,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. @@ -283,14 +453,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GeoBackupPolicy") @@ -337,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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 48cbac4bd0dc..7d0219a14b4a 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-05-01-preview"] = 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 @@ -81,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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,9 +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: Literal["2022-05-01-preview"] = 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") @@ -151,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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", @@ -180,9 +169,7 @@ def build_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 @@ -214,9 +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: Literal["2022-05-01-preview"] = 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 @@ -281,9 +266,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -310,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" @@ -373,9 +367,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -432,16 +424,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstanceFailoverGroup") @@ -607,9 +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: Literal["2022-05-01-preview"] = 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) @@ -669,9 +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: Literal["2022-05-01-preview"] = 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( @@ -733,9 +719,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -790,9 +774,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -861,9 +843,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -920,9 +900,7 @@ def _force_failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -992,9 +970,7 @@ def begin_force_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 809d5cc59820..080f20416280 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,25 +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: Literal["2020-11-01-preview"] = 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"), } @@ -75,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -104,21 +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: Literal["2020-11-01-preview"] = 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", @@ -135,18 +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: Literal["2020-11-01-preview"] = 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") @@ -171,25 +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: Literal["2020-11-01-preview"] = 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"), } @@ -198,24 +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: Literal["2020-11-01-preview"] = 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"), } @@ -225,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: @@ -249,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. @@ -274,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -331,16 +480,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstancePool") @@ -496,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -557,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -616,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -676,16 +817,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "InstancePoolUpdate") @@ -838,9 +977,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -884,151 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 19d8132c7a28..925833f4a489 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2021-11-01-preview"] = 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,9 +74,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -113,9 +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: Literal["2021-11-01-preview"] = 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") @@ -149,9 +140,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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", @@ -210,9 +199,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -239,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" @@ -302,9 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRule] = kwargs.pop("cls", None) request = build_get_request( @@ -446,16 +442,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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.IPv6FirewallRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "IPv6FirewallRule") @@ -531,9 +525,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( 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 d8f3cab824b6..5d8b81d3bee8 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2020-11-01-preview"] = 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 @@ -81,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -151,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -180,9 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -247,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -276,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" @@ -337,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -396,16 +390,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobAgent") @@ -568,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -630,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -694,9 +682,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -756,16 +742,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobAgentUpdate") @@ -925,9 +909,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 641fb30155ab..d69a7ecb54cd 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -167,9 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -231,9 +220,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -261,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" @@ -326,9 +324,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -478,16 +474,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobCredential") @@ -566,9 +560,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 7b1ccae776de..cbb0a8909b80 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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -61,9 +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: Literal["2020-11-01-preview"] = 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,63 +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: Literal["2020-11-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2020-11-01-preview"] = 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"), } @@ -171,72 +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: Literal["2020-11-01-preview"] = 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 = _format_url_section(_url, **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, @@ -245,18 +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: Literal["2020-11-01-preview"] = 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"), @@ -272,40 +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: Literal["2020-11-01-preview"] = 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"), } @@ -317,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: @@ -390,9 +374,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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,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" @@ -462,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, @@ -470,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. @@ -482,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 = { @@ -500,12 +628,10 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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, @@ -513,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, ) @@ -531,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, @@ -552,19 +688,18 @@ def _create_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -578,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) @@ -586,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. @@ -610,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 @@ -626,19 +772,18 @@ def begin_create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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, @@ -668,138 +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: Literal["2020-11-01-preview"] = 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, @@ -807,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. @@ -819,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 = { @@ -837,12 +856,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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, @@ -850,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, ) @@ -868,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, @@ -899,20 +906,17 @@ def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -926,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) @@ -934,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. @@ -967,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 @@ -985,20 +978,17 @@ def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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, @@ -1028,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 46a7876f5aa2..33244351aeba 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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -61,9 +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: Literal["2020-11-01-preview"] = 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 @@ -118,9 +112,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -225,9 +217,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -264,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" @@ -340,9 +341,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 f7d7754c86cd..f4da3588015b 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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 @@ -95,22 +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: Literal["2020-11-01-preview"] = 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"), } @@ -126,27 +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: Literal["2020-11-01-preview"] = 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"), } @@ -156,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, @@ -170,14 +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: Literal["2020-11-01-preview"] = 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", @@ -197,41 +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: Literal["2020-11-01-preview"] = 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"), } @@ -241,37 +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: Literal["2020-11-01-preview"] = 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"), } @@ -281,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: @@ -303,188 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 @@ -508,9 +311,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -539,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" @@ -612,9 +424,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -774,16 +584,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobStep") @@ -871,9 +679,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -908,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 94f949833187..a1f9e51d5b07 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 @@ -7,8 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,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, @@ -61,15 +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: Literal["2020-11-01-preview"] = 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"), @@ -77,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"), } @@ -105,36 +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: Literal["2020-11-01-preview"] = 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"), @@ -143,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 = _format_url_section(_url, **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 @@ -171,29 +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: Literal["2020-11-01-preview"] = 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"), @@ -201,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 = _format_url_section(_url, **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 @@ -237,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, @@ -253,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. @@ -266,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 @@ -293,9 +286,7 @@ def list_by_job_execution( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -309,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, @@ -324,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, ) @@ -332,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" @@ -362,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, @@ -375,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, @@ -384,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. @@ -397,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 @@ -426,9 +513,7 @@ def list_by_step( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -442,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, @@ -458,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, ) @@ -466,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" @@ -496,95 +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: Literal["2020-11-01-preview"] = 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 39fb41a6416a..93461cf93894 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -167,9 +158,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -231,9 +220,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -261,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" @@ -326,9 +324,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -478,16 +474,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "JobTargetGroup") @@ -566,9 +560,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 0d2c95dd5d57..f2245d75957d 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +81,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -159,9 +151,7 @@ def list_by_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -190,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,9 +264,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 ce8a47d3405d..7b0bab992beb 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +75,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -152,9 +143,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -216,9 +205,7 @@ def list_by_agent( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -246,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" @@ -311,9 +309,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -462,16 +458,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Job") @@ -550,9 +544,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 200036668f6b..9731467487f4 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2021-02-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2021-02-01-preview"] = 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 @@ -118,33 +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: Literal["2021-02-01-preview"] = 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"), } @@ -154,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( @@ -170,9 +161,7 @@ def build_disable_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 @@ -218,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, @@ -254,9 +337,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -315,16 +396,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LedgerDigestUploads") @@ -499,9 +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: Literal["2021-02-01-preview"] = 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) @@ -548,91 +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: Literal["2021-02-01-preview"] = 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, @@ -652,9 +644,7 @@ def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -732,9 +722,7 @@ def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 638428dbc167..646810b76ebb 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,74 +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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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"), @@ -119,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 = _format_url_section(_url, **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( @@ -147,9 +185,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 @@ -190,9 +226,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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", @@ -218,28 +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: Literal["2021-05-01-preview"] = 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"), @@ -249,72 +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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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, @@ -324,21 +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: Literal["2021-05-01-preview"] = 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"), } @@ -359,28 +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: Literal["2021-05-01-preview"] = 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"), @@ -388,48 +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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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"), @@ -440,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 = _format_url_section(_url, **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( @@ -469,9 +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: Literal["2021-05-01-preview"] = 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 @@ -514,9 +538,7 @@ def build_delete_by_resource_group_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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", @@ -543,29 +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: Literal["2021-05-01-preview"] = 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"), @@ -576,129 +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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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 @@ -709,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, @@ -726,159 +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: Literal["2021-05-01-preview"] = 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, (IO, 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 @@ -886,89 +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: Literal["2021-05-01-preview"] = 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, @@ -977,34 +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: Literal["2021-05-01-preview"] = 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, (IO, 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, ) @@ -1018,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. + ) -> 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 @@ -1078,7 +1310,7 @@ def begin_update( """ @overload - def begin_update( + def begin_copy( self, location_name: str, long_term_retention_server_name: str, @@ -1089,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 @@ -1099,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". @@ -1120,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 @@ -1139,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 @@ -1162,16 +1394,14 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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, @@ -1207,58 +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: Literal["2021-05-01-preview"] = 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, ) @@ -1272,87 +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: Literal["2021-05-01-preview"] = 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 @@ -1362,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 @@ -1370,27 +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: Literal["2021-05-01-preview"] = 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, @@ -1398,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)) @@ -1417,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 @@ -1454,9 +1719,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -1470,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, ) @@ -1486,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" @@ -1516,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 @@ -1547,9 +1827,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -1563,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, ) @@ -1577,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" @@ -1607,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 @@ -1641,9 +1939,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -1657,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, ) @@ -1672,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" @@ -1702,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( @@ -1727,16 +2252,14 @@ def _copy_by_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CopyLongTermRetentionBackupParameters") @@ -1922,9 +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: Literal["2021-05-01-preview"] = 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) @@ -1993,16 +2514,14 @@ def _update_by_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "UpdateLongTermRetentionBackupParameters") @@ -2188,9 +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: Literal["2021-05-01-preview"] = 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) @@ -2237,525 +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: Literal["2021-05-01-preview"] = 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: Literal["2021-05-01-preview"] = 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: Literal["2021-05-01-preview"] = 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: Literal["2021-05-01-preview"] = 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: Literal["2021-05-01-preview"] = 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: Literal["2021-05-01-preview"] = 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 2c605f3b7ff9..00edd6a1a4e5 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,38 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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 @@ -82,79 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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 @@ -163,53 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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, @@ -219,18 +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: Literal["2021-05-01-preview"] = 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"), } @@ -251,40 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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 @@ -293,83 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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 @@ -378,56 +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: Literal["2021-05-01-preview"] = 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 = _format_url_section(_url, **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, @@ -437,19 +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: Literal["2021-05-01-preview"] = 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"), } @@ -489,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 @@ -519,9 +705,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -574,9 +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: Literal["2021-05-01-preview"] = 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( @@ -640,9 +822,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) @@ -685,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 @@ -718,9 +895,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -734,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, ) @@ -750,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" @@ -780,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 @@ -815,9 +1001,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -831,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, ) @@ -846,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" @@ -876,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 @@ -908,9 +1113,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -924,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, ) @@ -938,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" @@ -968,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 @@ -1011,9 +1228,7 @@ def get_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -1073,9 +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: Literal["2021-05-01-preview"] = 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( @@ -1149,9 +1362,7 @@ def begin_delete_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) @@ -1194,111 +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: Literal["2021-05-01-preview"] = 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, @@ -1334,9 +1440,7 @@ def list_by_resource_group_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -1366,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" @@ -1399,100 +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: Literal["2021-05-01-preview"] = 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 58845b65dee3..57750e42f7da 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2020-11-01-preview"] = 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 @@ -118,33 +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: Literal["2020-11-01-preview"] = 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"), } @@ -154,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: @@ -178,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, @@ -214,9 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -275,16 +359,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LongTermRetentionPolicy") @@ -457,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -505,89 +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: Literal["2020-11-01-preview"] = 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 6edfc6203b09..d8e5a4e34f82 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +46,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -138,9 +131,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 438b78cd8c4f..be36e3f21a9e 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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( @@ -176,9 +168,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -327,16 +317,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "MaintenanceWindows") 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 4a9afc372c48..c64a8cdaa4ac 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2020-11-01-preview"] = 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 @@ -118,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, @@ -136,9 +120,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -165,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -197,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: @@ -221,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, @@ -257,9 +342,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -318,16 +401,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -503,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -572,16 +651,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -757,9 +834,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -805,90 +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: Literal["2020-11-01-preview"] = 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 1112f1410a6b..60b463dc8ebe 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-02-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -127,9 +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: Literal["2022-02-01-preview"] = 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") @@ -203,9 +194,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -233,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" @@ -305,9 +305,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -463,16 +461,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseAdvancedThreatProtection") 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 0274fb7e1093..11b7546e4287 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -56,9 +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: Literal["2020-11-01-preview"] = 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 @@ -108,9 +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: Literal["2020-11-01-preview"] = 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,9 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -244,9 +234,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -279,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,9 +347,7 @@ def list_by_table( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -381,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" @@ -457,9 +465,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 c47399bef173..64ed40dea0c0 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +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: Literal["2022-05-01-preview"] = 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 @@ -91,9 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 @@ -169,9 +161,7 @@ def list_by_location( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -200,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" @@ -263,9 +264,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 a12aa87fc41c..3858f4810c9b 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -95,9 +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: Literal["2020-11-01-preview"] = 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,9 +172,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -259,9 +249,7 @@ def list_by_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -293,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 2497c05adafb..5b477cb16237 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -45,9 +41,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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( @@ -194,16 +188,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") 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 454132a81daf..f18bd622b89f 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -50,9 +45,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 @@ -134,9 +127,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 aa2f3292b370..61c1530c62ae 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +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: Literal["2020-11-01-preview"] = 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,9 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -170,9 +162,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -201,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" @@ -266,9 +267,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 eb568d24ac61..c2a004a6b42f 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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, @@ -91,10 +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: Literal["2020-11-01-preview"] = 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 @@ -116,33 +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: Literal["2020-11-01-preview"] = 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"), } @@ -152,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: @@ -176,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, @@ -195,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) @@ -213,9 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -276,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 @@ -311,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 @@ -344,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. @@ -368,16 +453,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseSecurityAlertPolicy") @@ -424,90 +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: Literal["2020-11-01-preview"] = 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 eb30a7f95bf1..11d4418d9437 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -55,9 +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: Literal["2020-11-01-preview"] = 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,9 +144,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -184,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 3fea2d4b2407..02e1e912f1ab 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -40,44 +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: Literal["2020-11-01-preview"] = 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 = _format_url_section(_url, **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 @@ -86,71 +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 = _format_url_section(_url, **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: Literal["2020-11-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2020-11-01-preview"] = 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", @@ -172,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, @@ -185,16 +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: Literal["2020-11-01-preview"] = 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"), @@ -212,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, @@ -227,14 +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: Literal["2020-11-01-preview"] = 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"), @@ -252,76 +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: Literal["2020-11-01-preview"] = 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 = _format_url_section(_url, **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: Literal["2020-11-01-preview"] = 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"), } @@ -330,36 +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: Literal["2020-11-01-preview"] = 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"), @@ -371,12 +403,6 @@ def build_list_recommended_by_database_request( _url: str = _format_url_section(_url, **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") @@ -407,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. @@ -427,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, @@ -449,26 +478,391 @@ 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: Literal["2020-11-01-preview"] = 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, + 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) @@ -635,16 +1029,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabel") @@ -720,95 +1112,9 @@ def delete( # pylint: disable=inconsistent-return-statements :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: Literal["2020-11-01-preview"] = 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 - self, - resource_group_name: str, - managed_instance_name: str, - database_name: str, - schema_name: str, - table_name: str, - column_name: str, - **kwargs: Any - ) -> None: - """Disables sensitivity recommendations on a given column. - - :param resource_group_name: The name of the resource group that contains the resource. You can - 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: Default value is "recommended". Note that overriding this - default value may result in unsupported behavior. + :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) @@ -826,13 +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: Literal["2020-11-01-preview"] = 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, @@ -842,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, ) @@ -863,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, @@ -878,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. @@ -914,12 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, @@ -929,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, ) @@ -950,184 +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: Literal["2020-11-01-preview"] = 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. @@ -1136,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 @@ -1154,33 +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: Literal["2020-11-01-preview"] = 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, (IO, 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, ) @@ -1201,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"]: @@ -1225,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 @@ -1241,9 +1369,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -1257,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, ) @@ -1274,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" @@ -1304,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 a9f5d0571be6..059b556d81cd 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -53,9 +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: Literal["2020-11-01-preview"] = 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,9 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -177,9 +169,7 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -209,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" @@ -282,9 +283,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 3bd1c98c8b1c..06a3ab7cecb3 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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, @@ -91,10 +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: Literal["2020-11-01-preview"] = 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 @@ -116,33 +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: Literal["2020-11-01-preview"] = 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"), } @@ -152,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: @@ -176,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, @@ -213,9 +300,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -368,16 +453,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedTransparentDataEncryption") @@ -424,90 +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: Literal["2020-11-01-preview"] = 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 d72821f383ab..0f17c17550b1 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -52,9 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -98,9 +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: Literal["2020-11-01-preview"] = 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") @@ -146,9 +138,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -203,7 +193,7 @@ def get( rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Gets a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -224,8 +214,9 @@ def get( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -239,10 +230,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -271,7 +260,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("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -291,11 +280,11 @@ def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: _models.DatabaseVulnerabilityAssessmentRuleBaseline, + parameters: _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -316,13 +305,15 @@ def create_or_update( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :type parameters: + ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ @@ -339,7 +330,7 @@ def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -365,8 +356,9 @@ def create_or_update( 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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ @@ -379,9 +371,9 @@ def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaseline, IO], + parameters: Union[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated, IO], **kwargs: Any - ) -> _models.DatabaseVulnerabilityAssessmentRuleBaseline: + ) -> _models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated: """Creates or updates a database's vulnerability assessment rule baseline. :param resource_group_name: The name of the resource group that contains the resource. You can @@ -402,14 +394,16 @@ def create_or_update( and "default". Required. :type baseline_name: str or ~azure.mgmt.sql.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. Is either a - DatabaseVulnerabilityAssessmentRuleBaseline type or a IO type. Required. - :type parameters: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline or IO + DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated type or a IO type. Required. + :type parameters: + ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated 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: DatabaseVulnerabilityAssessmentRuleBaseline or the result of cls(response) - :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaseline + :return: DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated or the result of + cls(response) + :rtype: ~azure.mgmt.sql.models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -423,19 +417,17 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) + cls: ClsType[_models.DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaseline") + _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -467,7 +459,7 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("DatabaseVulnerabilityAssessmentRuleBaselineAutoGenerated", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -524,9 +516,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 f99c832c7d4d..450ea3988e48 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,24 +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: Literal["2020-11-01-preview"] = 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"), @@ -68,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"), } @@ -77,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, @@ -92,15 +90,13 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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"), @@ -121,29 +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: Literal["2020-11-01-preview"] = 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"), @@ -152,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"), } @@ -163,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, @@ -175,18 +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: Literal["2020-11-01-preview"] = 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"), @@ -204,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: @@ -229,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, @@ -246,49 +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: Literal["2020-11-01-preview"] = 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, @@ -296,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. @@ -312,63 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( + 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, ) - 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) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + _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, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" + if response.status_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 @@ -411,9 +441,7 @@ def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -457,41 +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: Literal["2020-11-01-preview"] = 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, @@ -500,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, @@ -561,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. @@ -577,59 +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: Literal["2020-11-01-preview"] = 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 2fc1effbaa46..2f14e246a66b 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2020-11-01-preview"] = 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 @@ -120,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, @@ -135,11 +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: Literal["2020-11-01-preview"] = 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", @@ -160,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -191,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: @@ -216,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, @@ -254,9 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -412,16 +495,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseVulnerabilityAssessment") @@ -507,9 +588,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -543,90 +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: Literal["2020-11-01-preview"] = 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 06dd8d8fa8bf..5627706e5d14 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-08-01-preview"] = 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,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -115,9 +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: Literal["2022-08-01-preview"] = 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,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -180,9 +169,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -217,9 +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: Literal["2022-08-01-preview"] = 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( @@ -251,9 +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: Literal["2022-08-01-preview"] = 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( @@ -285,9 +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: Literal["2022-08-01-preview"] = 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( @@ -319,9 +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: Literal["2022-08-01-preview"] = 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( @@ -353,9 +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: Literal["2022-08-01-preview"] = 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 @@ -418,9 +395,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -447,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" @@ -510,9 +496,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -569,16 +553,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabase") @@ -744,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -806,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -870,9 +848,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -932,16 +908,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseUpdate") @@ -1104,9 +1078,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1171,16 +1143,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseMoveDefinition") @@ -1334,9 +1304,7 @@ def begin_cancel_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1399,16 +1367,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseMoveDefinition") @@ -1562,9 +1528,7 @@ def begin_complete_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1627,16 +1591,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CompleteDatabaseRestoreDefinition") @@ -1792,9 +1754,7 @@ def begin_complete_restore( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1857,16 +1817,14 @@ 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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedDatabaseStartMoveDefinition") @@ -2020,9 +1978,7 @@ def begin_start_move( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -2085,9 +2041,7 @@ def list_inaccessible_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -2114,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 d87579e9a65e..1368c7dd35be 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2020-11-01-preview"] = 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,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -123,9 +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: Literal["2020-11-01-preview"] = 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") @@ -163,9 +154,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -225,9 +214,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -254,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" @@ -321,9 +319,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -380,16 +376,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAdministrator") @@ -555,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -621,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -689,9 +679,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 f3796461d79f..98f830f98db0 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-02-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -125,9 +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: Literal["2022-02-01-preview"] = 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") @@ -198,9 +189,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -227,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" @@ -296,9 +296,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -355,16 +353,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAdvancedThreatProtection") @@ -536,9 +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: Literal["2022-02-01-preview"] = 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 cc4ce7b3f3f2..ccddd68f2277 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2020-11-01-preview"] = 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,25 +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: Literal["2020-11-01-preview"] = 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,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -180,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: @@ -205,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, @@ -239,9 +321,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -298,16 +378,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceAzureADOnlyAuthentication") @@ -485,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -551,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -620,9 +694,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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,87 +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: Literal["2020-11-01-preview"] = 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 061f1b28d596..7ae4d2d0b86b 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-05-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 @@ -123,9 +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: Literal["2022-05-01-preview"] = 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") @@ -192,9 +183,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -221,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" @@ -284,9 +284,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -343,16 +341,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceDtc") @@ -513,9 +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: Literal["2022-05-01-preview"] = 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 46f5df2aed94..f40d72d45e08 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,27 +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: Literal["2020-11-01-preview"] = 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"), } @@ -71,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -107,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], @@ -117,9 +116,8 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -140,31 +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: Literal["2020-11-01-preview"] = 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"), @@ -178,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: @@ -205,136 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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 @@ -355,9 +214,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -384,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" @@ -452,9 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -511,16 +377,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceEncryptionProtector") @@ -689,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -736,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 c569afcb3302..6d55db7f88dd 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -53,9 +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: Literal["2020-11-01-preview"] = 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,9 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -122,9 +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: Literal["2020-11-01-preview"] = 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") @@ -158,9 +149,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -222,9 +211,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -252,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" @@ -315,9 +313,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -374,16 +370,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceKey") @@ -552,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -614,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -678,9 +668,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 d19162d7a06b..8f3b634e6f58 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,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 = _format_url_section(_url, **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, @@ -53,9 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -125,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -156,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: @@ -178,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, @@ -214,9 +339,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -275,16 +398,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceLongTermRetentionPolicy") @@ -460,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -509,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. @@ -522,76 +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: Literal["2020-11-01-preview"] = 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 5d571b983b7f..dacfc1b1a7d0 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -112,9 +104,7 @@ def build_cancel_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -174,9 +164,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -203,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" @@ -266,9 +265,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -335,9 +332,7 @@ def cancel( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 c009e7b551aa..86f9c672fb9a 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -92,10 +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: Literal["2020-11-01-preview"] = 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 @@ -118,25 +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: Literal["2020-11-01-preview"] = 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", @@ -156,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -186,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: @@ -211,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 @@ -240,9 +322,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -299,16 +379,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstancePrivateEndpointConnection") @@ -474,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -536,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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,9 +674,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -642,87 +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: Literal["2020-11-01-preview"] = 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 68ae445a8097..3632bf811c75 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -146,9 +138,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -175,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" @@ -238,9 +239,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 d69df779cefe..30a64f538ccc 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -47,9 +43,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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( @@ -111,16 +105,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TdeCertificate") @@ -264,9 +256,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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 2079ee9b94e9..35671b620dd3 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2020-11-01-preview"] = 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 @@ -116,25 +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: Literal["2020-11-01-preview"] = 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", @@ -154,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -184,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: @@ -209,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, @@ -244,9 +327,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -398,16 +479,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceVulnerabilityAssessment") @@ -489,9 +568,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -524,88 +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: Literal["2020-11-01-preview"] = 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 22b31439f403..ad2e92d3a4ee 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-08-01-preview"] = 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,9 +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: Literal["2022-08-01-preview"] = 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 @@ -116,9 +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: Literal["2022-08-01-preview"] = 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 @@ -155,9 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -167,7 +156,14 @@ def build_get_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -190,9 +186,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: Literal["2022-08-01-preview"] = 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 +197,14 @@ def build_create_or_update_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -225,9 +226,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -235,7 +234,14 @@ def build_delete_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -253,9 +259,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -266,7 +270,14 @@ def build_update_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -293,9 +304,7 @@ def build_failover_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -323,9 +332,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: Literal["2022-08-01-preview"] = 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 @@ -335,7 +342,14 @@ def build_list_outbound_network_dependencies_by_managed_instance_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -350,14 +364,53 @@ 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", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **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: Literal["2022-08-01-preview"] = 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", @@ -365,7 +418,14 @@ def build_start_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -374,17 +434,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: Literal["2022-08-01-preview"] = 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", @@ -392,7 +456,14 @@ def build_stop_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -401,7 +472,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( @@ -421,9 +495,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: Literal["2022-08-01-preview"] = 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 @@ -433,7 +505,14 @@ def build_list_by_managed_instance_request( ) # 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"), + "managedInstanceName": _SERIALIZER.url( + "managed_instance_name", + managed_instance_name, + "str", + max_length=63, + min_length=1, + pattern=r"^[a-z0-9][a-z0-9-]*$", + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -495,9 +574,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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -523,7 +600,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -576,9 +664,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -606,7 +692,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -659,9 +756,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -688,7 +783,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -751,9 +857,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -809,16 +913,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstance") @@ -974,9 +1076,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1035,9 +1135,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1094,9 +1192,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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1154,16 +1250,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedInstanceUpdate") @@ -1316,9 +1410,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1381,9 +1473,7 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1450,9 +1540,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1513,9 +1601,7 @@ def list_outbound_network_dependencies_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -1542,7 +1628,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" @@ -1576,9 +1673,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, @@ -1590,10 +1687,138 @@ def _start_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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.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, ) - cls: ClsType[None] = kwargs.pop("cls", None) + 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, @@ -1614,19 +1839,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 @@ -1642,22 +1875,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: Literal["2022-08-01-preview"] = 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, @@ -1668,9 +1900,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( @@ -1693,9 +1927,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, @@ -1707,10 +1941,8 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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, @@ -1731,19 +1963,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 @@ -1759,22 +1999,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: Literal["2022-08-01-preview"] = 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, @@ -1785,9 +2024,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( @@ -1858,9 +2099,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -1894,7 +2133,18 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) else: - request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_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 b8a2cb3c4fb8..8320f5db222f 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-08-01-preview"] = 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 @@ -87,9 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -127,9 +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: Literal["2022-08-01-preview"] = 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") @@ -170,9 +161,7 @@ def build_disable_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -240,9 +229,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -270,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" @@ -340,9 +338,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -401,16 +397,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedLedgerDigestUploads") @@ -589,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -657,9 +649,7 @@ def _disable_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -737,9 +727,7 @@ def begin_disable( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 4e730b8d2dc4..3bcb992c9ab9 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2020-11-01-preview"] = 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"), @@ -69,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"), } @@ -84,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, @@ -95,10 +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: Literal["2020-11-01-preview"] = 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 @@ -122,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, @@ -140,9 +128,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -171,28 +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: Literal["2020-11-01-preview"] = 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"), @@ -200,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"), } @@ -209,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: @@ -233,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, @@ -269,9 +354,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -330,16 +413,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -515,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -584,16 +663,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedBackupShortTermRetentionPolicy") @@ -769,9 +846,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -817,90 +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: Literal["2020-11-01-preview"] = 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 795e556319d1..067d526274fb 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2021-11-01-preview"] = 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 @@ -81,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -115,9 +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: Literal["2021-11-01-preview"] = 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") @@ -151,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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", @@ -180,9 +169,7 @@ def build_acquire_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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") @@ -250,9 +237,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -279,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" @@ -342,9 +338,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -401,16 +395,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerDnsAliasCreation") @@ -575,9 +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: Literal["2021-11-01-preview"] = 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) @@ -637,9 +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: Literal["2021-11-01-preview"] = 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( @@ -701,9 +689,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) @@ -763,16 +749,14 @@ def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerDnsAliasAcquisition") @@ -934,9 +918,7 @@ def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 7d44777a6c97..27e48cd22a11 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,20 +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: Literal["2020-11-01-preview"] = 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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -149,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: @@ -173,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. @@ -189,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 @@ -206,9 +290,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -250,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]: @@ -265,16 +347,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ManagedServerSecurityAlertPolicy") @@ -324,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", @@ -338,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. @@ -363,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", @@ -377,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. @@ -402,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]: @@ -414,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 @@ -437,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -484,86 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.ManagedServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_instance_request( - resource_group_name=resource_group_name, - managed_instance_name=managed_instance_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_instance.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedServerSecurityAlertPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_by_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies" - } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py new file mode 100644 index 000000000000..05df4cc0f681 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_network_security_perimeter_configurations_operations.py @@ -0,0 +1,442 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_server_request( + resource_group_name: str, server_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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}/networkSecurityPerimeterConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, server_name: str, nsp_config_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/networkSecurityPerimeterConfigurations/{nspConfigName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reconcile_request( + resource_group_name: str, server_name: str, nsp_config_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serverName": _SERIALIZER.url("server_name", server_name, "str"), + "nspConfigName": _SERIALIZER.url("nsp_config_name", nsp_config_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class NetworkSecurityPerimeterConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.sql.SqlManagementClient`'s + :attr:`network_security_perimeter_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_server( + self, resource_group_name: str, server_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Gets a list of NSP configurations for a server. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + resource_group_name=resource_group_name, + server_name=server_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_server.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_server.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations" + } + + @distributed_trace + def get( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets a network security perimeter configuration. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}" + } + + def _reconcile_initial( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> Optional[_models.NetworkSecurityPerimeterConfiguration]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.NetworkSecurityPerimeterConfiguration]] = kwargs.pop("cls", None) + + request = build_reconcile_request( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reconcile_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _reconcile_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } + + @distributed_trace + def begin_reconcile( + self, resource_group_name: str, server_name: str, nsp_config_name: str, **kwargs: Any + ) -> LROPoller[_models.NetworkSecurityPerimeterConfiguration]: + """Reconcile network security perimeter configuration for SQL Resource Provider. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param server_name: The name of the server. Required. + :type server_name: str + :param nsp_config_name: Required. + :type nsp_config_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NetworkSecurityPerimeterConfiguration or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.sql.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reconcile_initial( + resource_group_name=resource_group_name, + server_name=server_name, + nsp_config_name=nsp_config_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_reconcile.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/networkSecurityPerimeterConfigurations/{nspConfigName}/reconcile" + } diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_operations.py index b4e7d1ac8d89..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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,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]] @@ -44,9 +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: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -118,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 1406bc4ab193..ad381db1b8ec 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. # -------------------------------------------------------------------------- -import sys -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, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2021-02-01-preview"] = 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"), } @@ -76,16 +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: Literal["2021-02-01-preview"] = 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 @@ -106,21 +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: Literal["2021-02-01-preview"] = 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", @@ -138,28 +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: Literal["2021-02-01-preview"] = 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"), } @@ -168,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: @@ -193,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 @@ -222,9 +299,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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( @@ -263,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, @@ -278,32 +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: Literal["2021-02-01-preview"] = 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, (IO, 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, @@ -338,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. @@ -434,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 @@ -452,13 +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: Literal["2021-02-01-preview"] = 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) @@ -468,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, @@ -517,9 +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: Literal["2021-02-01-preview"] = 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( @@ -581,9 +542,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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) @@ -623,86 +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: Literal["2021-02-01-preview"] = 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 042e924f3172..ed8663ac5e99 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +39,23 @@ _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, - server_name: str, - private_endpoint_connection_name: str, - subscription_id: str, - **kwargs: Any +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: Literal["2020-11-01-preview"] = 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}/privateEndpointConnections/{privateEndpointConnectionName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections", ) # 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"), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_name, "str" - ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -82,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, private_endpoint_connection_name: str, @@ -92,10 +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: Literal["2020-11-01-preview"] = 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 @@ -118,25 +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, server_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: Literal["2020-11-01-preview"] = 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", @@ -156,28 +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_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, + 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: Literal["2020-11-01-preview"] = 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}/privateEndpointConnections", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}", ) # 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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -186,10 +178,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 PrivateEndpointConnectionsOperations: @@ -211,6 +200,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.PrivateEndpointConnection"]: + """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 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 PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = 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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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("PrivateEndpointConnectionListResult", 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}/privateEndpointConnections" + } + @distributed_trace def get( self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -240,9 +321,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-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( @@ -299,16 +378,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") @@ -470,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -532,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -596,9 +669,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -638,86 +709,3 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" } - - @distributed_trace - def list_by_server( - self, resource_group_name: str, server_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """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 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 PrivateEndpointConnection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.sql.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 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("PrivateEndpointConnectionListResult", 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}/privateEndpointConnections" - } 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 7ffaa32d0d4c..3341ca1aced1 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -145,9 +137,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -174,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" @@ -237,9 +238,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 4f9de30be067..1defc2b57e6d 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -45,9 +41,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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( @@ -194,16 +188,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") 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 aa45945feb5e..3597a31e9b4a 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-08-01-preview"] = 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 @@ -86,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -156,9 +148,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -185,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" @@ -259,9 +260,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 5bcdfac5d08c..68b9dce2f3d8 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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 @@ -83,9 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +142,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -179,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" @@ -242,9 +243,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 b89b2790f7e3..3b1b73bbbd18 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,10 +31,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-02-01-preview"] = 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 @@ -82,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -116,9 +108,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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", @@ -146,9 +136,7 @@ def build_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -181,9 +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: Literal["2022-02-01-preview"] = 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 @@ -216,9 +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: Literal["2022-02-01-preview"] = 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 @@ -283,9 +267,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -313,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" @@ -378,9 +371,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -433,9 +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: Literal["2022-02-01-preview"] = 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( @@ -500,9 +489,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -558,9 +545,7 @@ def _failover_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -632,9 +617,7 @@ def begin_failover( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -692,9 +675,7 @@ def _failover_allow_data_loss_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -766,9 +747,7 @@ def begin_failover_allow_data_loss( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) @@ -831,9 +810,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -860,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 2db5c44b9e85..cbb60ddd5568 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-08-01-preview"] = 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 @@ -86,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -159,9 +151,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -188,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" @@ -262,9 +263,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 69b3cf1b24fd..6b7338fad046 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2021-05-01-preview"] = 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 @@ -83,9 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 @@ -152,9 +144,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 = { @@ -181,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" @@ -244,9 +245,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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 2255a192cfb3..46c80edf3cbe 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2020-11-01-preview"] = 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,9 +77,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -124,9 +117,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -163,9 +154,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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", @@ -227,9 +216,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -257,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" @@ -310,16 +308,14 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CreateDatabaseRestorePointDefinition") @@ -485,9 +481,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -564,9 +558,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -636,9 +628,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 a51d342d2480..be5c0638f0d9 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -54,9 +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: Literal["2020-11-01-preview"] = 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 @@ -94,9 +94,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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( @@ -136,9 +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: Literal["2020-11-01-preview"] = 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 @@ -172,26 +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: Literal["2020-11-01-preview"] = 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"), @@ -209,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, @@ -222,16 +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: Literal["2020-11-01-preview"] = 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"), @@ -249,28 +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: Literal["2020-11-01-preview"] = 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", @@ -292,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, @@ -308,20 +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: Literal["2020-11-01-preview"] = 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"), @@ -339,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, @@ -359,14 +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: Literal["2020-11-01-preview"] = 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"), @@ -384,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 = _format_url_section(_url, **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: @@ -441,9 +467,7 @@ def list_current_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -474,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" @@ -609,16 +644,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") @@ -693,9 +726,7 @@ def list_recommended_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -726,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" @@ -761,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, @@ -769,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. @@ -787,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 = { @@ -806,23 +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: Literal["2020-11-01-preview"] = 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, ) @@ -840,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, @@ -856,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. @@ -873,68 +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: Literal["2020-11-01-preview"] = 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, @@ -942,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. @@ -960,70 +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: Literal["2020-11-01-preview"] = 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, @@ -1032,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. @@ -1052,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, @@ -1075,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. @@ -1095,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, @@ -1118,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. @@ -1136,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 = { @@ -1158,25 +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: Literal["2020-11-01-preview"] = 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, (IO, 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, @@ -1186,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, ) @@ -1203,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, @@ -1233,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. @@ -1248,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) @@ -1267,13 +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: Literal["2020-11-01-preview"] = 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, @@ -1283,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, ) @@ -1304,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 75a184ad6add..3378afc63f53 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2021-11-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -125,9 +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: Literal["2021-11-01-preview"] = 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") @@ -197,9 +188,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -226,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" @@ -295,9 +295,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -354,16 +352,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAdvancedThreatProtection") @@ -532,9 +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: Literal["2021-11-01-preview"] = 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 6997cc2763f2..547c0eda7901 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -45,9 +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: Literal["2020-11-01-preview"] = 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,9 +74,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +106,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -193,9 +183,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -260,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -402,16 +388,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Advisor") 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 78ef6a64a3f4..efdba353b19b 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -43,9 +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: Literal["2020-11-01-preview"] = 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,9 +70,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -282,16 +272,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAutomaticTuning") 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 1eacb626b52f..a95c87c0bea8 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2020-11-01-preview"] = 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,25 +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: Literal["2020-11-01-preview"] = 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,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -180,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: @@ -205,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, @@ -239,9 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -298,16 +377,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAzureADAdministrator") @@ -476,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -542,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -611,9 +684,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -653,86 +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: Literal["2020-11-01-preview"] = 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 cdffb991ac31..516dee85a322 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2020-11-01-preview"] = 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,25 +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: Literal["2020-11-01-preview"] = 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,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -180,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: @@ -205,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, @@ -239,9 +320,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -298,16 +377,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerAzureADOnlyAuthentication") @@ -482,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -548,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -617,9 +690,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -659,86 +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: Literal["2020-11-01-preview"] = 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 720032c9f90c..f409c1116c71 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -48,9 +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: Literal["2021-11-01-preview"] = 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,9 +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: Literal["2021-11-01-preview"] = 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 @@ -115,9 +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: Literal["2021-11-01-preview"] = 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,9 +181,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -214,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" @@ -277,9 +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: Literal["2021-11-01-preview"] = 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( @@ -336,16 +339,14 @@ 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: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") @@ -509,9 +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: Literal["2021-11-01-preview"] = 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_communication_links_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py deleted file mode 100644 index 9136cfb8a9d8..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_communication_links_operations.py +++ /dev/null @@ -1,632 +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. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -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]] - -_SERIALIZER = Serializer() -_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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2014-04-01"] = 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}/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 = _format_url_section(_url, **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_create_or_update_request( - resource_group_name: str, server_name: str, communication_link_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: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/communicationLinks/{communicationLinkName}", - ) # 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 = _format_url_section(_url, **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="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 -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2014-04-01"] = 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}/communicationLinks", - ) # 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 = _format_url_section(_url, **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 ServerCommunicationLinksOperations: - """ - .. 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. - """ - - 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 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: Literal["2014-04-01"] = 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 = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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 - 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: Literal["2014-04-01"] = 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 = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_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}" - } - - 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: Literal["2014-04-01"] = 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, (IO, 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 = 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 - 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. - - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2014-04-01"] = 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, 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, - 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: 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_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: Literal["2014-04-01"] = 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" - } 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 e83885f2befb..92ece1a27d14 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-08-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -125,9 +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: Literal["2022-08-01-preview"] = 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") @@ -197,9 +188,7 @@ def list_by_managed_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -226,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" @@ -295,9 +295,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -354,16 +352,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerConfigurationOption") @@ -530,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 f2c4c364137b..fd10f00e89f0 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2021-05-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2021-05-01-preview"] = 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 @@ -114,32 +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: Literal["2021-05-01-preview"] = 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"), } @@ -149,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: @@ -173,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, @@ -206,9 +289,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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( @@ -265,16 +346,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerConnectionPolicy") @@ -437,9 +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: Literal["2021-05-01-preview"] = 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) @@ -484,86 +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: Literal["2021-05-01-preview"] = 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 39804aa852ef..00862d6f2b98 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-02-01-preview"] = 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 @@ -85,9 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -125,9 +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: Literal["2022-02-01-preview"] = 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") @@ -197,9 +188,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 = { @@ -226,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" @@ -293,9 +293,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( @@ -352,16 +350,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerDevOpsAuditingSettings") @@ -524,9 +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: Literal["2022-02-01-preview"] = 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 20165d869d07..6ef44e1dd810 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -76,15 +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: Literal["2020-11-01-preview"] = 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,17 +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: Literal["2020-11-01-preview"] = 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", @@ -135,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -165,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( @@ -177,9 +166,7 @@ def build_acquire_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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") @@ -227,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 @@ -256,9 +334,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -310,9 +386,7 @@ def _create_or_update_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -384,9 +458,7 @@ def begin_create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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) @@ -443,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -507,9 +577,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -550,88 +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: Literal["2020-11-01-preview"] = 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, @@ -651,16 +637,14 @@ def _acquire_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerDnsAliasAcquisition") @@ -822,9 +806,7 @@ def begin_acquire( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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 654ebc50296b..221dca7b7a9b 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2020-11-01-preview"] = 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 @@ -81,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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") @@ -151,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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,9 +201,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -241,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" @@ -302,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -361,16 +357,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerKey") @@ -542,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -604,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -666,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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 8be93e6e1148..8561edca4b97 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,9 +105,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -140,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 20cad287d16d..98fd0c0d2071 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,30 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,20 +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: Literal["2020-11-01-preview"] = 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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -149,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: @@ -173,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. @@ -189,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 @@ -206,9 +290,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -250,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]: @@ -265,16 +347,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") @@ -324,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", @@ -338,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. @@ -363,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", @@ -377,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. @@ -402,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]: @@ -414,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 @@ -437,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -484,86 +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: Literal["2020-11-01-preview"] = 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 789bb9bac90e..4bfeba51dcfd 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2021-11-01-preview"] = 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 @@ -81,9 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 @@ -115,9 +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: Literal["2021-11-01-preview"] = 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") @@ -151,9 +142,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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", @@ -214,9 +203,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 = { @@ -243,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" @@ -306,9 +304,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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( @@ -365,16 +361,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerTrustCertificate") @@ -540,9 +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: Literal["2021-11-01-preview"] = 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) @@ -602,9 +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: Literal["2021-11-01-preview"] = 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( @@ -666,9 +656,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-11-01-preview"] = 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 72ed1e0ad8a4..a3542668ca53 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -76,16 +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: Literal["2020-11-01-preview"] = 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,21 +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: Literal["2020-11-01-preview"] = 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", @@ -138,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -168,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( @@ -180,9 +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: Literal["2020-11-01-preview"] = 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 @@ -226,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 @@ -255,9 +333,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -314,16 +390,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerTrustGroup") @@ -489,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -551,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -615,9 +685,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -658,88 +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: Literal["2020-11-01-preview"] = 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 @@ -759,9 +745,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -788,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 87b888e7620f..5ea155075462 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,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: Literal["2014-04-01"] = 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 @@ -55,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 = _format_url_section(_url, **path_format_arguments) # type: ignore @@ -94,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. @@ -109,7 +105,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2014-04-01"] = 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 = { @@ -136,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" @@ -147,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 e45855df300a..32e535018ac1 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -80,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], @@ -90,10 +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: Literal["2020-11-01-preview"] = 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 @@ -116,25 +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: Literal["2020-11-01-preview"] = 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", @@ -154,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -184,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: @@ -209,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, @@ -244,9 +325,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -398,16 +477,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") @@ -489,9 +566,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -524,86 +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: Literal["2020-11-01-preview"] = 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 b649caf10419..07d2132e2240 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-08-01-preview"] = 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") @@ -75,9 +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: Literal["2022-08-01-preview"] = 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 @@ -105,9 +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: Literal["2022-08-01-preview"] = 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 @@ -139,9 +130,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -174,9 +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: Literal["2022-08-01-preview"] = 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") @@ -209,9 +196,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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,9 +222,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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") @@ -273,9 +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: Literal["2022-08-01-preview"] = 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") @@ -309,9 +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: Literal["2022-08-01-preview"] = 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 @@ -417,16 +396,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") @@ -480,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -508,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" @@ -559,9 +545,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -588,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" @@ -651,9 +646,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -705,16 +698,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Server") @@ -863,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -924,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -983,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1039,16 +1024,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerUpdate") @@ -1194,9 +1177,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1259,16 +1240,14 @@ def _import_database_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ImportNewDatabaseDefinition") @@ -1421,9 +1400,7 @@ def begin_import_database( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) @@ -1482,9 +1459,7 @@ def _refresh_status_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -1551,9 +1526,7 @@ def begin_refresh_status( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 9d5f7eee4343..000000000000 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_service_objectives_operations.py +++ /dev/null @@ -1,270 +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. -# -------------------------------------------------------------------------- -import sys -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, _format_url_section - -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]] - -_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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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 = _format_url_section(_url, **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: Literal["2014-04-01"] = 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: Literal["2014-04-01"] = 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 9ef5096952b8..d26eebfa2b58 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,10 +28,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -45,9 +41,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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 @@ -78,9 +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: Literal["2020-11-01-preview"] = 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") @@ -152,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -283,16 +273,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlAgentConfiguration") 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 37e3dacfbf75..ec260ebd6048 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,9 +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: Literal["2022-02-01-preview"] = 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 @@ -98,9 +97,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -183,9 +180,7 @@ def list_by_sql_vulnerability_assessment( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSetListResult] = kwargs.pop("cls", None) error_map = { @@ -214,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" @@ -293,9 +299,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 3febde812522..cbc1bc0eb27d 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 @@ -6,6 +6,7 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -53,9 +54,7 @@ def build_create_or_update_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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") @@ -235,16 +234,14 @@ def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentBaselineSet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineListInput") 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 fa810c9d4524..d13d5c2fec58 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,9 +53,7 @@ def build_execute_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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", @@ -119,9 +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: Literal["2022-02-01-preview"] = 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_execute_request( @@ -195,9 +191,7 @@ def begin_execute( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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) 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 702eb5e023bd..e15d29f9667a 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 @@ -6,8 +6,10 @@ # 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 import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -54,9 +56,7 @@ def build_list_by_baseline_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -101,9 +101,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -149,9 +147,7 @@ def build_create_or_update_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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") @@ -241,9 +237,7 @@ def list_by_baseline( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult] = kwargs.pop("cls", None) error_map = { @@ -273,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" @@ -355,9 +360,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) request = build_get_request( @@ -534,16 +537,14 @@ def create_or_update( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.DatabaseSqlVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabaseSqlVulnerabilityAssessmentRuleBaselineInput") 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 ae2d3cdeebd6..2dbe6440529e 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,9 +53,7 @@ def build_delete_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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", @@ -146,9 +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: Literal["2022-02-01-preview"] = 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( 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 df2eeaa85930..bc6b06feba7d 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,9 +55,7 @@ def build_list_by_scan_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -101,9 +100,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -192,9 +189,7 @@ def list_by_scan( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.SQLVulnerabilityAssessmentScanListResult] = kwargs.pop("cls", None) error_map = { @@ -224,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" @@ -306,9 +312,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 c0d97d43a60d..9e881cdb8532 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,9 +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: Literal["2022-02-01-preview"] = 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 @@ -98,9 +97,7 @@ def build_get_request( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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 @@ -183,9 +180,7 @@ def list_by_sql_vulnerability_assessments( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) error_map = { @@ -214,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" @@ -291,9 +297,7 @@ def get( system_database_name: Literal["master"] = kwargs.pop( "system_database_name", _params.pop("systemDatabaseName", "master") ) - api_version: Literal["2022-02-01-preview"] = 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.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 647f2a5b4d68..ed9022cb32bf 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 @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +43,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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", @@ -126,9 +119,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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( 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 742e608be50c..fc7576b97369 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-02-01-preview"] = 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 @@ -83,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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 @@ -123,9 +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: Literal["2022-02-01-preview"] = 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") @@ -195,9 +186,7 @@ def list_by_server( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) error_map = { @@ -224,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" @@ -293,9 +293,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -438,16 +436,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-02-01-preview"] = 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.SqlVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlVulnerabilityAssessment") 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 a80298f98398..4134ceb8c9d3 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -29,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-08-01-preview"] = 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 @@ -83,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -121,9 +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: Literal["2022-08-01-preview"] = 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") @@ -161,9 +152,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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", @@ -223,9 +212,7 @@ def list_by_instance( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -252,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" @@ -320,9 +318,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -465,16 +461,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "StartStopManagedInstanceSchedule") @@ -555,9 +549,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 6faf70b81165..3233d0476500 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -44,9 +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: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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 @@ -133,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -161,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" @@ -219,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 444144377bdf..47bfa9cb0162 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-05-01-preview"] = 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,9 +109,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 = { @@ -145,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 bae6f90030ad..165ad9b71db3 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -76,16 +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: Literal["2020-11-01-preview"] = 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,21 +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: Literal["2020-11-01-preview"] = 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", @@ -138,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -168,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( @@ -180,9 +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: Literal["2020-11-01-preview"] = 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 @@ -214,9 +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: Literal["2020-11-01-preview"] = 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 @@ -261,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. @@ -288,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -347,16 +421,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncAgent") @@ -519,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -581,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -645,9 +713,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -688,88 +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: Literal["2020-11-01-preview"] = 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 @@ -799,9 +783,7 @@ def generate_key( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -861,9 +843,7 @@ def list_linked_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -891,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 519b95b81fec..1c91dad63e1a 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2020-11-01-preview"] = 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,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -103,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, @@ -117,15 +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: Literal["2020-11-01-preview"] = 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"), @@ -146,31 +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: Literal["2020-11-01-preview"] = 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"), @@ -183,22 +168,17 @@ def build_list_logs_request( _url: str = _format_url_section(_url, **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, @@ -208,13 +188,11 @@ def build_cancel_sync_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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"), @@ -229,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, @@ -240,15 +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: Literal["2020-11-01-preview"] = 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"), @@ -263,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, @@ -274,18 +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: Literal["2020-11-01-preview"] = 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"), @@ -300,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, @@ -317,16 +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: Literal["2020-11-01-preview"] = 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"), @@ -342,30 +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: Literal["2020-11-01-preview"] = 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"), @@ -378,12 +356,22 @@ def build_delete_request( _url: str = _format_url_section(_url, **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, @@ -391,19 +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: Literal["2020-11-01-preview"] = 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"), @@ -418,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -454,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: @@ -494,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -522,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" @@ -556,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, @@ -567,51 +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: Literal["2020-11-01-preview"] = 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. @@ -623,93 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + 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, ) - 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) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) + _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, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + response = pipeline_response.http_response - begin_refresh_hub_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema" - } + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - @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. + deserialized = self._deserialize("SyncGroup", pipeline_response) - :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager 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 {}) + if cls: + return cls(pipeline_response, deserialized, {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) - cls: ClsType[_models.SyncFullSchemaPropertiesListResult] = kwargs.pop("cls", None) + 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, @@ -718,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. @@ -794,99 +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: Literal["2020-11-01-preview"] = 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. @@ -897,79 +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: Literal["2020-11-01-preview"] = 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, @@ -981,19 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -1007,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. @@ -1034,63 +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: Literal["2020-11-01-preview"] = 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, @@ -1110,21 +1092,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, @@ -1134,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, ) @@ -1148,7 +1128,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) @@ -1156,20 +1136,17 @@ def _create_or_update_initial( if response.status_code == 200: deserialized = self._deserialize("SyncGroup", pipeline_response) - if response.status_code == 201: - deserialized = self._deserialize("SyncGroup", pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) 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, @@ -1180,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. @@ -1210,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, @@ -1221,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. @@ -1251,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, @@ -1260,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. @@ -1292,16 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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, @@ -1337,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, @@ -1355,19 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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, ) @@ -1381,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. @@ -1408,73 +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: Literal["2020-11-01-preview"] = 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, @@ -1483,34 +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: Literal["2020-11-01-preview"] = 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, (IO, 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, ) @@ -1528,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. @@ -1644,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 @@ -1658,30 +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: Literal["2020-11-01-preview"] = 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, @@ -1689,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)) @@ -1710,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. @@ -1727,19 +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: Literal["2020-11-01-preview"] = 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, @@ -1748,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 863e4d12c80a..59462c194e06 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -84,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, @@ -96,10 +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: Literal["2020-11-01-preview"] = 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 @@ -122,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, @@ -138,11 +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: Literal["2020-11-01-preview"] = 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", @@ -162,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, @@ -174,15 +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: Literal["2020-11-01-preview"] = 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", @@ -202,40 +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: Literal["2020-11-01-preview"] = 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"), } @@ -245,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, @@ -259,18 +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: Literal["2020-11-01-preview"] = 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"), @@ -286,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, @@ -301,15 +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: Literal["2020-11-01-preview"] = 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"), @@ -325,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: @@ -347,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, @@ -387,9 +467,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -450,16 +528,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncMember") @@ -645,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -715,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -792,9 +864,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -858,16 +928,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SyncMember") @@ -1050,9 +1118,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -1100,193 +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: Literal["2020-11-01-preview"] = 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: Literal["2020-11-01-preview"] = 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, @@ -1307,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -1384,9 +1261,7 @@ def begin_refresh_member_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -1428,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 a7a2993c2432..596f5cbdf0a4 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 @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -47,9 +43,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = 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( @@ -107,16 +101,14 @@ 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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TdeCertificate") @@ -256,9 +248,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_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 920b556640e6..73ed0a56671d 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -44,9 +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: Literal["2020-11-01-preview"] = 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,9 +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: Literal["2020-11-01-preview"] = 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 @@ -133,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 = { @@ -161,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" @@ -219,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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 38598e2ca287..9b4f400df91e 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -48,9 +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: Literal["2022-08-01-preview"] = 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 @@ -87,9 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = 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 @@ -127,9 +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: Literal["2022-08-01-preview"] = 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") @@ -202,9 +193,7 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 = { @@ -232,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" @@ -303,9 +303,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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( @@ -364,16 +362,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "LogicalDatabaseTransparentDataEncryption") @@ -555,9 +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: Literal["2022-08-01-preview"] = kwargs.pop( - "api_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 93c1b687975c..e503f736e52c 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 @@ -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. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -51,9 +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: Literal["2021-02-01-preview"] = 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 @@ -121,9 +115,7 @@ def list_by_instance_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-02-01-preview"] = 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 = { @@ -151,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 6aa231d55278..4da792b8b73b 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -46,9 +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: Literal["2022-05-01-preview"] = 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 @@ -72,9 +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: Literal["2022-05-01-preview"] = 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 @@ -104,9 +97,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 @@ -136,9 +127,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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", @@ -164,9 +153,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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") @@ -200,9 +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: Literal["2022-05-01-preview"] = 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 @@ -258,9 +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: Literal["2022-05-01-preview"] = 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 = { @@ -285,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" @@ -332,9 +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: Literal["2022-05-01-preview"] = 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 = { @@ -360,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" @@ -419,9 +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: Literal["2022-05-01-preview"] = 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( @@ -472,9 +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: Literal["2022-05-01-preview"] = 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( @@ -531,9 +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: Literal["2022-05-01-preview"] = 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) @@ -591,16 +588,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualClusterUpdate") @@ -753,9 +748,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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) @@ -814,9 +807,7 @@ def _update_dns_servers_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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( @@ -884,9 +875,7 @@ def begin_update_dns_servers( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-05-01-preview"] = 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 f745293ffb54..dc64076295d8 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,26 +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: Literal["2020-11-01-preview"] = 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"), } @@ -76,16 +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: Literal["2020-11-01-preview"] = 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,21 +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: Literal["2020-11-01-preview"] = 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", @@ -138,28 +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: Literal["2020-11-01-preview"] = 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"), } @@ -168,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: @@ -193,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 @@ -222,9 +302,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -281,16 +359,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualNetworkRule") @@ -456,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -518,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -582,9 +654,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -624,85 +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: Literal["2020-11-01-preview"] = 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 03e700550e22..90b650365afd 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,34 +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: Literal["2020-11-01-preview"] = 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"), } @@ -84,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, @@ -96,10 +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: Literal["2020-11-01-preview"] = 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 @@ -122,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, @@ -138,11 +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: Literal["2020-11-01-preview"] = 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", @@ -162,35 +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: Literal["2020-11-01-preview"] = 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"), } @@ -199,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: @@ -224,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, @@ -264,9 +351,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -327,16 +412,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadClassifier") @@ -528,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -598,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -675,9 +754,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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) @@ -719,92 +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: Literal["2020-11-01-preview"] = 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 4eb607a99da0..256ddf46b852 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 @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +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, @@ -31,10 +32,6 @@ from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -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]] @@ -42,32 +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: Literal["2020-11-01-preview"] = 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"), } @@ -82,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, @@ -93,10 +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: Literal["2020-11-01-preview"] = 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 @@ -118,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, @@ -133,11 +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: Literal["2020-11-01-preview"] = 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", @@ -156,29 +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: Literal["2020-11-01-preview"] = 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"), } @@ -187,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: @@ -212,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 @@ -243,9 +326,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("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( @@ -304,16 +385,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.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) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadGroup") @@ -489,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2020-11-01-preview") - ) + api_version: str = kwargs.pop("api_version", _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) @@ -552,9 +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: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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( @@ -619,9 +694,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-11-01-preview"] = kwargs.pop( - "api_version", _params.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,88 +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: Literal["2020-11-01-preview"] = 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 20c07d4455c7..527d37a87900 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/administrator_delete.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_azure_ad_administrators.begin_delete( + client.server_azure_ad_administrators.begin_delete( resource_group_name="sqlcrudtest-4799", server_name="sqlcrudtest-6440", administrator_name="ActiveDirectory", ).result() - print(response) -# 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 76a4c845ea88..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_azure_ad_only_authentications.begin_delete( + client.server_azure_ad_only_authentications.begin_delete( resource_group_name="sqlcrudtest-4799", server_name="sqlcrudtest-6440", authentication_name="Default", ).result() - print(response) -# 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 c4b92f07ce5c..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_operations.cancel( + client.database_operations.cancel( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-6661", database_name="testdb", operation_id="f779414b-e748-4925-8cfe-c8598f7660ae", ) - print(response) -# 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 86d93b9c65ee..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pool_operations.cancel( + client.elastic_pool_operations.cancel( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-6661", elastic_pool_name="testpool", operation_id="f779414b-e748-4925-8cfe-c8598f7660ae", ) - print(response) -# 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 26e74b0f2893..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.job_executions.cancel( + client.job_executions.cancel( resource_group_name="group1", server_name="server1", job_agent_name="agent1", job_name="job1", job_execution_id="5A86BF65-43AC-F258-2524-9E92992F97CA", ) - print(response) -# 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 54cf628ff8b4..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_operations.cancel( + client.managed_instance_operations.cancel( resource_group_name="sqlcrudtest-7398", managed_instance_name="sqlcrudtest-4645", operation_id="11111111-1111-1111-1111-111111111111", ) - print(response) -# 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..177f92e30da2 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 @@ -49,6 +49,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 1e6905b0c786..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sensitivity_labels.delete( + client.sensitivity_labels.delete( resource_group_name="myRG", server_name="myServer", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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_database_configured_backup_storage_redundancy.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py index d2944209261d..31ab292a4a54 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_configured_backup_storage_redundancy.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py index 052689a3aca1..1600b7a452f4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_copy_mode.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseCopyMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseCopyMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py index 9d9482994b36..72e335a34fc3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py index 711541112ae5..0a9a2c9fe397 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseDefaultMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py index 345a3b82be84..520c099a8bf4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_default_mode_with_keys_and_encryption_protector.py @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py index 246eb7fd5816..e4f26a19c926 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_ledger.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseLedger.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseLedger.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py index b6072c509e03..dc7c33d152d1 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_maintenance_configuration.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py index 7c19c2231c4a..61428c8029a7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_min.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseMin.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMin.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py index f4cad8dd68dc..db28d045c929 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_named_replica.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseNamedReplica.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseNamedReplica.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py index 295bdcc8cfdc..edadf1ac8933 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_pitr_mode.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabasePITRMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabasePITRMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py index 3afea3a4344b..c7c30d185f7f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_secondary_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseSecondaryMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseSecondaryMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py index 34e96de963b4..3cb64d9b8b23 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_standby_mode.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseStandbyMode.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseStandbyMode.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py index dfef7c3f2bf9..d1a7939f8668 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_vbs_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py index cf25b6278e3d..4f84673bf446 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_database_with_availability_zone.py @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDatabaseWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py index cf5dc8d21a18..565071026df2 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_pitr.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py index ec95a00ec0ef..26cacec27ac8 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_recovery.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py index acc69f0cd9a6..8bb52bcaf34e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_dw_database_cross_subscription_restore.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_elastic_pool_with_availability_zone.py index afd1c989d29c..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 336f934359c1..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.maintenance_windows.create_or_update( + client.maintenance_windows.create_or_update( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdwdb", @@ -38,9 +38,8 @@ def main(): "properties": {"timeRanges": [{"dayOfWeek": "Saturday", "duration": "PT60M", "startTime": "00:00:00"}]} }, ) - print(response) -# 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/create_vcore_database_by_service_objective.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py index 07d8a39f77a3..60d5dcb22602 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_service_objective.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py index d4c4af7b71ce..ab44b6f097a4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/create_vcore_database_by_sku_name_capacity.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py b/sdk/sql/azure-mgmt-sql/generated_samples/data_masking_policy_create_or_update_max.py index ae81b6b823d8..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 017f35059eb0..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_encryption_protectors.begin_revalidate( + client.database_encryption_protectors.begin_revalidate( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", database_name="sqlcrudtestdb-2342", encryption_protector_name="current", ).result() - print(response) -# 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 e86cceca6f5d..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_encryption_protectors.begin_revert( + client.database_encryption_protectors.begin_revert( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", database_name="sqlcrudtestdb-2342", encryption_protector_name="current", ).result() - print(response) -# 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_metrics_list_with_filter.py b/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_list_with_filter.py deleted file mode 100644 index 520bc953da70..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/database_metrics_list_with_filter.py +++ /dev/null @@ -1,44 +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 database_metrics_list_with_filter.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.databases.list_metrics( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - database_name="3481", - filter="name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsListWithFilter.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 8dee415547a2..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.restore_points.delete( + client.restore_points.delete( resource_group_name="Default-SQL-SouthEastAsia", server_name="testserver", database_name="testDatabase", restore_point_name="131546477590000000", ) - print(response) -# 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 816812ab3109..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-02-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 288766e2d07d..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-02-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 f7f59f2fd0f9..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-02-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 eb0331c24327..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-02-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 37dfcc560683..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-02-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 e8dc23f334e7..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-02-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 21b6ca02ccc5..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-02-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 37a60c75f9c9..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-02-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 2258d6821930..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_sql_vulnerability_assessment_rule_baselines.delete( + client.database_sql_vulnerability_assessment_rule_baselines.delete( resource_group_name="vulnerabilityaseessmenttest-4711", server_name="vulnerabilityaseessmenttest-6411", database_name="testdb", @@ -37,9 +37,8 @@ def main(): baseline_name="default", rule_id="VA1001", ) - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-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 bfbc378838fa..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-02-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 89bf3f72618d..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-02-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 45fcf2070d00..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-02-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 c17ce4e94c7a..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-02-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 1ccd2f4803dc..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_sql_vulnerability_assessment_execute_scan.begin_execute( + client.database_sql_vulnerability_assessment_execute_scan.begin_execute( resource_group_name="vulnerabilityassessmenttest-4711", server_name="vulnerabilityassessmenttest-6411", database_name="testdb", vulnerability_assessment_name="default", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-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 13a4fdc9949f..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-02-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 4ac95e8e8dec..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_vulnerability_assessments.delete( + client.database_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", server_name="vulnerabilityaseessmenttest-6440", database_name="testdb", vulnerability_assessment_name="default", ) - print(response) -# 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 b1c764149d26..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_vulnerability_assessment_rule_baselines.delete( + client.database_vulnerability_assessment_rule_baselines.delete( resource_group_name="vulnerabilityaseessmenttest-4799", server_name="vulnerabilityaseessmenttest-6440", database_name="testdb", @@ -37,9 +37,8 @@ def main(): rule_id="VA1001", baseline_name="default", ) - print(response) -# 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 e67ddb60d072..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.database_vulnerability_assessment_scans.begin_initiate_scan( + client.database_vulnerability_assessment_scans.begin_initiate_scan( resource_group_name="vulnerabilityassessmenttest-4711", server_name="vulnerabilityassessmenttest-6411", database_name="testdb", vulnerability_assessment_name="default", scan_id="scan01", ).result() - print(response) -# 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_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py index c45d354710cf..6d6909387575 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_database.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.databases.begin_delete( + client.databases.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdb", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DeleteDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/DeleteDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/delete_instance_pool.py index ae1fe71503a5..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 @@ -29,13 +29,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.instance_pools.begin_delete( + client.instance_pools.begin_delete( resource_group_name="group1", instance_pool_name="testIP", ).result() - print(response) -# 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 e674d63eae37..c7c87f6de594 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/delete_job.py @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.jobs.delete( + client.jobs.delete( resource_group_name="group1", server_name="server1", job_agent_name="agent1", job_name="job1", ) - print(response) -# 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 1910de35326f..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.job_agents.begin_delete( + client.job_agents.begin_delete( resource_group_name="group1", server_name="server1", job_agent_name="agent1", ).result() - print(response) -# 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 37449770b808..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.job_credentials.delete( + client.job_credentials.delete( resource_group_name="group1", server_name="server1", job_agent_name="agent1", credential_name="cred1", ) - print(response) -# 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 56053116c258..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.job_steps.delete( + client.job_steps.delete( resource_group_name="group1", server_name="server1", job_agent_name="agent1", job_name="job1", step_name="step1", ) - print(response) -# 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 dde433114f55..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.job_target_groups.delete( + client.job_target_groups.delete( resource_group_name="group1", server_name="server1", job_agent_name="agent1", target_group_name="targetGroup1", ) - print(response) -# 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 0bd4c3f8ea38..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workload_classifiers.begin_delete( + client.workload_classifiers.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdb", workload_group_name="wlm_workloadgroup", workload_classifier_name="wlm_workloadclassifier", ).result() - print(response) -# 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 fcd45ca4b5dd..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workload_groups.begin_delete( + client.workload_groups.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdb", workload_group_name="wlm_workloadgroup", ).result() - print(response) -# 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 aef8a014a7c4..1d4ac3e62233 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 @@ -29,14 +29,13 @@ def main(): subscription_id="f2669dff-5f08-45dd-b857-b2a60b72cdc9", ) - response = client.distributed_availability_groups.begin_delete( + client.distributed_availability_groups.begin_delete( resource_group_name="testrg", managed_instance_name="testcl", distributed_availability_group_name="dag", ).result() - print(response) -# 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..3dc12e1ce427 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 @@ -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/distributed_availability_groups_set_role.py b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py new file mode 100644 index 000000000000..a990d819f577 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/distributed_availability_groups_set_role.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python distributed_availability_groups_set_role.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.distributed_availability_groups.begin_set_role( + resource_group_name="testrg", + managed_instance_name="testcl", + distributed_availability_group_name="dag", + parameters={"instanceRole": "Primary", "roleChangeType": "Forced"}, + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-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_activity_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_activity_list.py deleted file mode 100644 index 302e9555e80d..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_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_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="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", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolActivityList.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 b6b111ab5651..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pools.begin_delete( + client.elastic_pools.begin_delete( resource_group_name="sqlcrudtest-3129", server_name="sqlcrudtest-228", elastic_pool_name="sqlcrudtest-3851", ).result() - print(response) -# 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_metrics_list_with_filter.py b/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_list_with_filter.py deleted file mode 100644 index dfb5613f3f66..000000000000 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_list_with_filter.py +++ /dev/null @@ -1,44 +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_metrics_list_with_filter.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = SqlManagementClient( - credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", - ) - - response = client.elastic_pools.list_metrics( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - elastic_pool_name="3481", - filter="name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsListWithFilter.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 467457b3bd41..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.encryption_protectors.begin_revalidate( + client.encryption_protectors.begin_revalidate( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", encryption_protector_name="current", ).result() - print(response) -# 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.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py index 77cb62f2ab15..26857778948c 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ExportDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_using_database_extensions.py new file mode 100644 index 000000000000..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/export_database_with_network_isolation.py b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py index a05c68c90ba6..c360726e568d 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/export_database_with_network_isolation.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ExportDatabaseWithNetworkIsolation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ExportDatabaseWithNetworkIsolation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py b/sdk/sql/azure-mgmt-sql/generated_samples/extended_database_azure_monitor_auditing_create_min.py index 484d98f1b65f..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_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py index ce0336dfb4fb..27d599fd765a 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_database.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.databases.begin_failover( + client.databases.begin_failover( resource_group_name="group1", server_name="testServer", database_name="testDatabase", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/FailoverDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/FailoverDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_elastic_pool.py index 462bd6bc8393..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pools.begin_failover( + client.elastic_pools.begin_failover( resource_group_name="group1", server_name="testServer", elastic_pool_name="testElasticPool", ).result() - print(response) -# 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 7361035822f1..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/2020-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 752e6920c641..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.failover_groups.begin_delete( + client.failover_groups.begin_delete( resource_group_name="Default", server_name="failover-group-primary-server", failover_group_name="failover-group-test-1", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-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 ef197914664c..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/2020-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 f3cdaf43be42..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/2020-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 a128a58374a6..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/2020-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 8d53d19722dd..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/2020-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/service_objective_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py similarity index 76% rename from sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py index 73e1c51aa36e..325fce6060f3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/service_objective_get.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/failover_group_try_planned_before_forced_failover.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python service_objective_get.py + python failover_group_try_planned_before_forced_failover.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.service_objectives.get( - resource_group_name="group1", - server_name="sqlcrudtest", - service_objective_name="29dd7459-4a7c-4e56-be22-f0adda49440d", - ) + response = client.failover_groups.begin_try_planned_before_forced_failover( + resource_group_name="Default", + server_name="failovergroupsecondaryserver", + failover_group_name="failovergrouptest3", + ).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/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 aab88e20be6d..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/2020-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 1a94151fa33f..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 @@ -29,13 +29,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instances.begin_failover( + client.managed_instances.begin_failover( resource_group_name="group1", managed_instance_name="instanceName", ).result() - print(response) -# 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 0e1e24370a3f..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.firewall_rules.delete( + client.firewall_rules.delete( resource_group_name="firewallrulecrudtest-9886", server_name="firewallrulecrudtest-2368", firewall_rule_name="firewallrulecrudtest-7011", ) - print(response) -# 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 3220104022b0..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 @@ -29,15 +29,14 @@ def main(): subscription_id="a3473687-7581-41e1-ac24-6bcca5843f07", ) - response = client.database_extensions.get( + client.database_extensions.get( resource_group_name="rg_a1f9d6f8-30d5-4228-9504-8a364361bca3", server_name="srv_65858e0f-b1d1-4bdc-8351-a7da86ca4939", database_name="11aa6c5e-58ed-4693-b303-3b8e3131deaa", extension_name="polybaseimport", ) - print(response) -# 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_database_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py index b391c439d1e6..1b5838136c41 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_database_with_availability_zone.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetDatabaseWithAvailabilityZone.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_elastic_pool_with_availability_zone.py index 859428235265..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_vcore_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py index 556f241a43d7..11b40a122bea 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetVCoreDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py index 28d0374ddbd8..21937b9b6d19 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_default_enclave.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py index 7ced979d5692..799a0ddb263f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_vbs_enclave.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetVCoreDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py index fc70f561e356..5fd75aafa4c4 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/get_vcore_database_with_expand_equals_keys.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py b/sdk/sql/azure-mgmt-sql/generated_samples/get_workload_classifier.py index e7468437a3c3..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.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py index 42a3d23dca71..95e36574cdc7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ImportDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_using_database_extensions.py new file mode 100644 index 000000000000..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_database_with_network_isolation.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py index 77bb06f8c83d..5bfb963461bd 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/import_database_with_network_isolation.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ImportDatabaseWithNetworkIsolation.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ImportDatabaseWithNetworkIsolation.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/import_new_database.py index 1f2bb5b5af2d..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 d6151c956726..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.instance_failover_groups.begin_delete( + client.instance_failover_groups.begin_delete( resource_group_name="Default", location_name="Japan East", failover_group_name="failover-group-test-1", ).result() - print(response) -# 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 0f1d5fa77024..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/2021-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 fdee6ffb6a56..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.ipv6_firewall_rules.delete( + client.ipv6_firewall_rules.delete( resource_group_name="firewallrulecrudtest-9886", server_name="firewallrulecrudtest-2368", firewall_rule_name="firewallrulecrudtest-7011", ) - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2021-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 ccff9a831532..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/2021-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 fc6d5c05bb4f..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/2021-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 618a8bbe01b5..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/2021-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_databases_by_elastic_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py index 1c59bdd77425..180ba950c601 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_databases_by_elastic_pool.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListDatabasesByElasticPool.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListDatabasesByElasticPool.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_elastic_pool_operations.py index 11205104afdd..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/list_vcore_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py index d1ec0cb7faf2..99137f679e33 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListVCoreDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py index ae814ceb5594..0aebfc0cad19 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_databases_enclave_type_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py index a792f36a2331..bcc793701585 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/list_vcore_inaccessible_databases_by_server.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py b/sdk/sql/azure-mgmt-sql/generated_samples/location_capability_list_by_location.py index 06c607b4b823..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 d9ff78a5b66f..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.long_term_retention_backups.begin_delete( + client.long_term_retention_backups.begin_delete( location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", ).result() - print(response) -# 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..ab15cfbd39e5 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/long_term_retention_policy_create_or_update.py @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-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 37e5ddb7ea17..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_cancel_move( + client.managed_databases.begin_cancel_move( resource_group_name="group1", managed_instance_name="testInstanceSrc", database_name="testDatabase", @@ -37,9 +37,8 @@ def main(): "destinationManagedDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/managedInstances/testInstanceTgt/databases/testDatabase" }, ).result() - print(response) -# 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..3f228a786313 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 @@ -49,6 +49,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 be580835629b..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_sensitivity_labels.delete( + client.managed_database_sensitivity_labels.delete( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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 e3aec68d5378..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_complete_restore( + client.managed_databases.begin_complete_restore( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", parameters={"lastBackupName": "testdb1_log4"}, ).result() - print(response) -# 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 3bf39375b120..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_complete_move( + client.managed_databases.begin_complete_move( resource_group_name="group1", managed_instance_name="testInstanceSrc", database_name="testDatabase", @@ -37,9 +37,8 @@ def main(): "destinationManagedDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/managedInstances/testInstanceTgt/databases/testDatabase" }, ).result() - print(response) -# 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 f02a32218b69..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_delete( + client.managed_databases.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", managed_instance_name="managedInstance", database_name="testdb", ).result() - print(response) -# 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 7e0eddb653d8..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_sensitivity_labels.disable_recommendation( + client.managed_database_sensitivity_labels.disable_recommendation( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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 91f9169d6347..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_sensitivity_labels.enable_recommendation( + client.managed_database_sensitivity_labels.enable_recommendation( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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 aaf5fd7876fb..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_sensitivity_labels.update( + client.managed_database_sensitivity_labels.update( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", @@ -71,9 +71,8 @@ def main(): ] }, ) - print(response) -# 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_metrics_definitions_list.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py similarity index 78% rename from sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py rename to sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py index 5ad837baa643..ad98b071583f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/elastic_pool_metrics_definitions_list.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_database_sensitivity_labels_list_by_database.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-sql # USAGE - python elastic_pool_metrics_definitions_list.py + python managed_database_sensitivity_labels_list_by_database.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,15 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.elastic_pools.list_metric_definitions( - resource_group_name="sqlcrudtest-6730", - server_name="sqlcrudtest-9007", - elastic_pool_name="3481", + response = client.managed_database_sensitivity_labels.list_by_database( + resource_group_name="myRG", + managed_instance_name="myManagedInstanceName", + database_name="myDatabase", ) for item in response: print(item) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-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 5d298ccdca88..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_recommended_sensitivity_labels.update( + client.managed_database_recommended_sensitivity_labels.update( resource_group_name="myRG", managed_instance_name="myManagedInstanceName", database_name="myDatabase", @@ -41,9 +41,8 @@ def main(): ] }, ) - print(response) -# 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 4fc316af17f8..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_start_move( + client.managed_databases.begin_start_move( resource_group_name="group1", managed_instance_name="testInstanceSrc", database_name="testDatabase", @@ -38,9 +38,8 @@ def main(): "operationMode": "Copy", }, ).result() - print(response) -# 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 4aae88382c6b..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_databases.begin_start_move( + client.managed_databases.begin_start_move( resource_group_name="group1", managed_instance_name="testInstanceSrc", database_name="testDatabase", @@ -37,9 +37,8 @@ def main(): "destinationManagedDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/managedInstances/testInstanceTgt/databases/testDatabase" }, ).result() - print(response) -# 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 33be4404e456..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_vulnerability_assessments.delete( + client.managed_database_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", managed_instance_name="vulnerabilityaseessmenttest-6440", database_name="testdb", vulnerability_assessment_name="default", ) - print(response) -# 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 075cb14470b5..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_vulnerability_assessment_rule_baselines.delete( + client.managed_database_vulnerability_assessment_rule_baselines.delete( resource_group_name="vulnerabilityaseessmenttest-4799", managed_instance_name="vulnerabilityaseessmenttest-6440", database_name="testdb", @@ -37,9 +37,8 @@ def main(): rule_id="VA1001", baseline_name="default", ) - print(response) -# 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 cc2ccb0a1147..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( + client.managed_database_vulnerability_assessment_scans.begin_initiate_scan( resource_group_name="vulnerabilityassessmenttest-4711", managed_instance_name="vulnerabilityassessmenttest-6411", database_name="testdb", vulnerability_assessment_name="default", scan_id="scan01", ).result() - print(response) -# 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 48581ce4a599..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_administrators.begin_delete( + client.managed_instance_administrators.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", managed_instance_name="managedInstance", administrator_name="ActiveDirectory", ).result() - print(response) -# 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 c9a4656700be..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_azure_ad_only_authentications.begin_delete( + client.managed_instance_azure_ad_only_authentications.begin_delete( resource_group_name="Default-SQL-SouthEastAsia", managed_instance_name="managedInstance", authentication_name="Default", ).result() - print(response) -# 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 29c89ef643ab..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,16 +26,15 @@ 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_delete( + client.managed_instances.begin_delete( resource_group_name="testrg", managed_instance_name="testinstance", ).result() - print(response) -# 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 58ac0bfe8a91..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_encryption_protectors.begin_revalidate( + client.managed_instance_encryption_protectors.begin_revalidate( resource_group_name="sqlcrudtest-7398", managed_instance_name="sqlcrudtest-4645", encryption_protector_name="current", ).result() - print(response) -# 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 00212ac55852..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_keys.begin_delete( + client.managed_instance_keys.begin_delete( resource_group_name="sqlcrudtest-7398", managed_instance_name="sqlcrudtest-4645", key_name="someVault_someKey_01234567890123456789012345678901", ).result() - print(response) -# 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 31f8f5e4e66c..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.long_term_retention_managed_instance_backups.begin_delete( + client.long_term_retention_managed_instance_backups.begin_delete( location_name="japaneast", managed_instance_name="testInstance", database_name="testDatabase", backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", ).result() - print(response) -# 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/managed_instance_long_term_retention_policy_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py new file mode 100644 index 000000000000..14537be360ce --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/generated_samples/managed_instance_long_term_retention_policy_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.sql import SqlManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-sql +# USAGE + python managed_instance_long_term_retention_policy_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SqlManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-1111-2222-3333-444444444444", + ) + + response = client.managed_instance_long_term_retention_policies.begin_delete( + resource_group_name="testResourceGroup", + managed_instance_name="testInstance", + database_name="testDatabase", + policy_name="default", + ).result() + print(response) + + +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-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 f2b69934688e..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_private_endpoint_connections.begin_delete( + client.managed_instance_private_endpoint_connections.begin_delete( resource_group_name="Default", managed_instance_name="test-cl", private_endpoint_connection_name="private-endpoint-connection-name", ).result() - print(response) -# 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 33f0d11ae0c4..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000001", ) - response = client.managed_instance_tde_certificates.begin_create( + client.managed_instance_tde_certificates.begin_create( resource_group_name="testtdecert", managed_instance_name="testtdecert", parameters={"properties": {"privateBlob": "MIIXXXXXXXX"}}, ).result() - print(response) -# 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..7cb3b4805680 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( @@ -38,7 +38,7 @@ def main(): "administratorLoginPassword": "PLACEHOLDER", "collation": "SQL_Latin1_General_CP1_CI_AS", "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 +53,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 0bd29afdeec7..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_instance_vulnerability_assessments.delete( + client.managed_instance_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", managed_instance_name="vulnerabilityaseessmenttest-6440", vulnerability_assessment_name="default", ) - print(response) -# 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 67151e54722c..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.managed_server_dns_aliases.begin_delete( + client.managed_server_dns_aliases.begin_delete( resource_group_name="Default", managed_instance_name="dns-mi", dns_alias_name="dns-alias-mi", ).result() - print(response) -# 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_delete.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_delete.py rename to sdk/sql/azure-mgmt-sql/generated_samples/outbound_firewall_rule_create.py index 97cc14bf612d..6a4c88253737 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_delete.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_delete.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.delete( + 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/ServerCommunicationLinkDelete.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 580f103275a5..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.outbound_firewall_rules.begin_delete( + client.outbound_firewall_rules.begin_delete( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-6661", outbound_rule_fqdn="server.database.windows.net", ).result() - print(response) -# 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_database_default_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py index 5095dd5779a9..2a297701b6cb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_default_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchDatabaseDefaultEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseDefaultEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py index 59a501db0735..591e320d9358 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_database_vbs_enclave.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchDatabaseVBSEnclave.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseVBSEnclave.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_instance_pool.py index 856593c9ffec..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/patch_vcore_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py index 8df904ecd43c..329a494c8e7f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchVCoreDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py index 8d167b03abed..0e4f30ed6638 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_assign_maintenance_configuration.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py index 156840558c10..8a0c8d9cc1fb 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_reset_maintenance_configuration.py @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py index 38dce910c356..1f25f62ee858 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/patch_vcore_database_with_keys_and_encryption_protector.py @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py index abe4288cd416..b3841eb4e899 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/pause_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PauseDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PauseDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/private_endpoint_connection_delete.py index 3917f9646351..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.private_endpoint_connections.begin_delete( + client.private_endpoint_connections.begin_delete( resource_group_name="Default", server_name="test-svr", private_endpoint_connection_name="private-endpoint-connection-name", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-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 bb4cce4cc496..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/2020-11-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 b0d9735dc51e..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/2020-11-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 d6e27e2c6a88..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/2020-11-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 c2b07f780886..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sensitivity_labels.disable_recommendation( + client.sensitivity_labels.disable_recommendation( resource_group_name="myRG", server_name="myServer", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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 d59975a15795..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sensitivity_labels.enable_recommendation( + client.sensitivity_labels.enable_recommendation( resource_group_name="myRG", server_name="myServer", database_name="myDatabase", @@ -37,9 +37,8 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) -# 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_get.py b/sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status_mi.py similarity index 83% rename from sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.py rename to sdk/sql/azure-mgmt-sql/generated_samples/refresh_external_governance_status_mi.py index 6911134744c6..ca685d5a42a9 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_communication_link_get.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_get.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,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_communication_links.get( + 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/ServerCommunicationLinkGet.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/rename_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py index 536e4550d297..2784b848da0e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/rename_database.py @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.databases.rename( + client.databases.rename( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdb", @@ -37,9 +37,8 @@ def main(): "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/newtestdb" }, ) - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RenameDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/RenameDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/replication_link_delete.py index e1f10e6072dc..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.replication_links.begin_delete( + client.replication_links.begin_delete( resource_group_name="Default", server_name="sourcesvr", database_name="gamma-db", link_id="4891ca10-ebd0-47d7-9182-c722651780fb", ).result() - print(response) -# 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 983e2e17ee62..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.long_term_retention_backups.begin_delete_by_resource_group( + client.long_term_retention_backups.begin_delete_by_resource_group( resource_group_name="testResourceGroup", location_name="japaneast", long_term_retention_server_name="testserver", long_term_retention_database_name="testDatabase", backup_name="55555555-6666-7777-8888-999999999999;131637960820000000", ).result() - print(response) -# 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 2eb361811a3b..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( + client.long_term_retention_managed_instance_backups.begin_delete_by_resource_group( resource_group_name="testResourceGroup", 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() - print(response) -# 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/resume_database.py b/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py index 7a189b6773e4..13f0f471607e 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/resume_database.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ResumeDatabase.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ResumeDatabase.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py b/sdk/sql/azure-mgmt-sql/generated_samples/sensitivity_labels_current_update.py index b92df352c987..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sensitivity_labels.update( + client.sensitivity_labels.update( resource_group_name="myRG", server_name="myServer", database_name="myDatabase", @@ -73,9 +73,8 @@ def main(): ] }, ) - print(response) -# 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 87f9c2344418..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 @@ -29,7 +29,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.recommended_sensitivity_labels.update( + client.recommended_sensitivity_labels.update( resource_group_name="myRG", server_name="myServer", database_name="myDatabase", @@ -41,9 +41,8 @@ def main(): ] }, ) - print(response) -# 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..140163b7303f 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_create.py @@ -52,6 +52,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 1d89eaca3b5e..7273eef43aa3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_delete.py @@ -29,13 +29,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.servers.begin_delete( + client.servers.begin_delete( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-6661", ).result() - print(response) -# 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 80a6c94a1304..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_dns_aliases.begin_delete( + client.server_dns_aliases.begin_delete( resource_group_name="Default", server_name="dns-alias-server", dns_alias_name="dns-alias-name-1", ).result() - print(response) -# 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 977824130c2f..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_keys.begin_delete( + client.server_keys.begin_delete( resource_group_name="sqlcrudtest-7398", server_name="sqlcrudtest-4645", key_name="someVault_someKey_01234567890123456789012345678901", ).result() - print(response) -# 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 d059cbfd7b90..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 @@ -29,14 +29,13 @@ def main(): subscription_id="38e0dc56-907f-45ba-a97c-74233baad471", ) - response = client.server_trust_certificates.begin_delete( + client.server_trust_certificates.begin_delete( resource_group_name="testrg", managed_instance_name="testcl", certificate_name="customerCertificateName", ).result() - print(response) -# 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 b2eb24b0d89f..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_trust_groups.begin_delete( + client.server_trust_groups.begin_delete( resource_group_name="Default", location_name="Japan East", server_trust_group_name="server-trust-group-test", ).result() - print(response) -# 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..2888da3d88d3 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/server_update.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/server_update.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/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 4d87229ce241..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.server_vulnerability_assessments.delete( + client.server_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", server_name="vulnerabilityaseessmenttest-6440", vulnerability_assessment_name="default", ) - print(response) -# 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 84bb76a24f7d..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-0000-0000-0000-000000000001", ) - response = client.tde_certificates.begin_create( + client.tde_certificates.begin_create( resource_group_name="testtdecert", server_name="testtdecert", parameters={"properties": {"privateBlob": "MIIXXXXXXXX"}}, ).result() - print(response) -# 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 4e12146256ee..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-02-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 121d0d9b0910..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-02-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 0a6daeed89bc..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-02-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 86b8fd3b0354..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-02-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 d92aae9d3057..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-02-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 50c8d5808f55..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_vulnerability_assessments.delete( + client.sql_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", server_name="vulnerabilityaseessmenttest-6440", vulnerability_assessment_name="default", ) - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-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 0cd52a7cf2ea..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-02-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 983fffd74868..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-02-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 dfaab96dedd3..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-02-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 c6963c7a22ac..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-02-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 d6ff3d83d2f8..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_vulnerability_assessment_rule_baselines.delete( + client.sql_vulnerability_assessment_rule_baselines.delete( resource_group_name="vulnerabilityaseessmenttest-4711", server_name="vulnerabilityaseessmenttest-6411", vulnerability_assessment_name="default", baseline_name="default", rule_id="VA1001", ) - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-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 9dbf4a7dec6f..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-02-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 558be462ae90..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-02-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 3bd9a1fb0e3d..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-02-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 0bd2dded3e32..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-02-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 497f26ca0dbf..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_vulnerability_assessment_execute_scan.begin_execute( + client.sql_vulnerability_assessment_execute_scan.begin_execute( resource_group_name="vulnerabilityassessmenttest-4711", server_name="vulnerabilityassessmenttest-6411", vulnerability_assessment_name="default", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-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 a5018b9028ad..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-02-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 1d60eb1bc6e3..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 @@ -36,6 +36,6 @@ def main(): 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 0e549544924f..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.start_stop_managed_instance_schedules.delete( + client.start_stop_managed_instance_schedules.delete( resource_group_name="schedulerg", managed_instance_name="schedulemi", start_stop_schedule_name="default", ) - print(response) -# 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 0179cee60d51..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 @@ -36,6 +36,6 @@ def main(): 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 b6560bb782e8..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_agents.begin_delete( + client.sync_agents.begin_delete( resource_group_name="syncagentcrud-65440", server_name="syncagentcrud-8475", sync_agent_name="syncagentcrud-3187", ).result() - print(response) -# 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 44dd66dbd5b4..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_groups.cancel_sync( + client.sync_groups.cancel_sync( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", ) - print(response) -# 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 233e9e7f5ff7..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_groups.begin_delete( + client.sync_groups.begin_delete( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", ).result() - print(response) -# 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 dab504e2f495..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_groups.begin_refresh_hub_schema( + client.sync_groups.begin_refresh_hub_schema( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", ).result() - print(response) -# 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 820f76ceb692..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 @@ -29,15 +29,14 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_groups.trigger_sync( + client.sync_groups.trigger_sync( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", ) - print(response) -# 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 e1ffaed7d98e..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_members.begin_delete( + client.sync_members.begin_delete( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", sync_member_name="syncgroupcrud-4879", ).result() - print(response) -# 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 783965eb2ec8..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 @@ -29,16 +29,15 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sync_members.begin_refresh_member_schema( + client.sync_members.begin_refresh_member_schema( resource_group_name="syncgroupcrud-65440", server_name="syncgroupcrud-8475", database_name="syncgroupcrud-4328", sync_group_name="syncgroupcrud-3187", sync_member_name="syncgroupcrud-4879", ).result() - print(response) -# 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_database_hyperscale_migration_perform_cutover.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py index 7333e3337a07..bd5b342c9b82 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_perform_cutover.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py index d97a71851802..e21b57e318cc 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/update_database_hyperscale_migration_with_manual_cutover.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py b/sdk/sql/azure-mgmt-sql/generated_samples/update_job_agent.py index 6367b898c94b..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/upgrade_data_warehouse.py b/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py index 3329756d0281..bc3ea7e8b9a7 100644 --- a/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py +++ b/sdk/sql/azure-mgmt-sql/generated_samples/upgrade_data_warehouse.py @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.databases.begin_upgrade_data_warehouse( + client.databases.begin_upgrade_data_warehouse( resource_group_name="Default-SQL-SouthEastAsia", server_name="testsvr", database_name="testdwdb", ).result() - print(response) -# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/UpgradeDataWarehouse.json +# x-ms-original-file: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpgradeDataWarehouse.json if __name__ == "__main__": main() diff --git a/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py b/sdk/sql/azure-mgmt-sql/generated_samples/virtual_cluster_delete.py index 2d3d33c79358..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 @@ -29,13 +29,12 @@ def main(): subscription_id="20d7082a-0fc7-4468-82bd-542694d5042b", ) - response = client.virtual_clusters.begin_delete( + client.virtual_clusters.begin_delete( resource_group_name="testrg", virtual_cluster_name="vc-subnet1-f769ed71-b3ad-491a-a9d5-26eeceaa6be2", ).result() - print(response) -# 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 09063092517b..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 @@ -29,14 +29,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.virtual_network_rules.begin_delete( + client.virtual_network_rules.begin_delete( resource_group_name="Default", server_name="vnet-test-svr", virtual_network_rule_name="vnet-firewall-rule", ).result() - print(response) -# 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()